diff options
| author | 2020-12-21 23:24:11 +0100 | |
|---|---|---|
| committer | 2021-01-25 16:20:57 +0100 | |
| commit | af9b59e6a1a36997d7017f4841f4a934ca1ade98 (patch) | |
| tree | f5eb124cbbfbd49b0f6195257752b62176a520ed /src | |
| parent | 7b1ccb403ad284b896a4e710fab578e397f101c0 (diff) | |
| download | libplist-af9b59e6a1a36997d7017f4841f4a934ca1ade98.tar.gz libplist-af9b59e6a1a36997d7017f4841f4a934ca1ade98.tar.bz2 | |
Replace malloc + memset with calloc where appropriate
calloc is faster for big allocations. It's also simpler.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/xplist.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/xplist.c b/src/xplist.c index 3a92142..2f98983 100644 --- a/src/xplist.c +++ b/src/xplist.c | |||
| @@ -211,8 +211,7 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth) | |||
| 211 | struct TM _btime; | 211 | struct TM _btime; |
| 212 | struct TM *btime = gmtime64_r(&timev, &_btime); | 212 | struct TM *btime = gmtime64_r(&timev, &_btime); |
| 213 | if (btime) { | 213 | if (btime) { |
| 214 | val = (char*)malloc(24); | 214 | val = (char*)calloc(1, 24); |
| 215 | memset(val, 0, 24); | ||
| 216 | struct tm _tmcopy; | 215 | struct tm _tmcopy; |
| 217 | copy_TM64_to_tm(btime, &_tmcopy); | 216 | copy_TM64_to_tm(btime, &_tmcopy); |
| 218 | val_len = strftime(val, 24, "%Y-%m-%dT%H:%M:%SZ", &_tmcopy); | 217 | val_len = strftime(val, 24, "%Y-%m-%dT%H:%M:%SZ", &_tmcopy); |
