diff options
author | Daniel Gustafsson <daniel@yesql.se> | 2018-04-14 22:42:04 +0200 |
---|---|---|
committer | Jay Satiro <raysatiro@yahoo.com> | 2018-04-15 03:00:37 -0400 |
commit | 94400f32e9016d2eaea2db583f6e213c36b1eb1d (patch) | |
tree | d8c79e652dfa3a9b52b0056cdbe00a66411a502b /lib/nwlib.c | |
parent | 2b126cd7083ddf1308ebc447cabd1983b16a99fa (diff) | |
download | curl-94400f32e9016d2eaea2db583f6e213c36b1eb1d.tar.gz |
all: Refactor malloc+memset to use calloc
When a zeroed out allocation is required, use calloc() rather than
malloc() followed by an explicit memset(). The result will be the
same, but using calloc() everywhere increases consistency in the
codebase and avoids the risk of subtle bugs when code is injected
between malloc and memset by accident.
Closes https://github.com/curl/curl/pull/2497
Diffstat (limited to 'lib/nwlib.c')
-rw-r--r-- | lib/nwlib.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/nwlib.c b/lib/nwlib.c index 290cbe31f..215d933ac 100644 --- a/lib/nwlib.c +++ b/lib/nwlib.c @@ -186,11 +186,9 @@ int GetOrSetUpData(int id, libdata_t **appData, app_data = (libdata_t *) get_app_data(id); if(!app_data) { - app_data = malloc(sizeof(libdata_t)); + app_data = calloc(1, sizeof(libdata_t)); if(app_data) { - memset(app_data, 0, sizeof(libdata_t)); - app_data->tenbytes = malloc(10); app_data->lock = NXMutexAlloc(0, 0, &liblock); |