summaryrefslogtreecommitdiffstats
path: root/src/xplist.c
diff options
context:
space:
mode:
authorGravatar Rosen Penev2020-12-21 23:24:11 +0100
committerGravatar Nikias Bassen2021-01-25 16:20:57 +0100
commitaf9b59e6a1a36997d7017f4841f4a934ca1ade98 (patch)
treef5eb124cbbfbd49b0f6195257752b62176a520ed /src/xplist.c
parent7b1ccb403ad284b896a4e710fab578e397f101c0 (diff)
downloadlibplist-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/xplist.c')
-rw-r--r--src/xplist.c3
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)
struct TM _btime;
struct TM *btime = gmtime64_r(&timev, &_btime);
if (btime) {
- val = (char*)malloc(24);
- memset(val, 0, 24);
+ val = (char*)calloc(1, 24);
struct tm _tmcopy;
copy_TM64_to_tm(btime, &_tmcopy);
val_len = strftime(val, 24, "%Y-%m-%dT%H:%M:%SZ", &_tmcopy);