diff options
author | Xin LI <delphij@FreeBSD.org> | 2008-10-23 00:15:00 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2008-10-23 00:15:00 +0000 |
commit | 9bbd8028fa77bd549aba5fecf5eb872bf0832a32 (patch) | |
tree | 16a0f59db102b3c13cfd79f02ae44084875ddf6f /usr.sbin/nscd/agents/services.c | |
parent | 59e2759db82d62c1f79e798c57e7fa7c157ec8ee (diff) | |
download | src-9bbd8028fa77bd549aba5fecf5eb872bf0832a32.tar.gz src-9bbd8028fa77bd549aba5fecf5eb872bf0832a32.zip |
Replace malloc() + memset() with calloc. This corrects a misuse of
memset() as a side effect.
Notes
Notes:
svn path=/head/; revision=184186
Diffstat (limited to 'usr.sbin/nscd/agents/services.c')
-rw-r--r-- | usr.sbin/nscd/agents/services.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/usr.sbin/nscd/agents/services.c b/usr.sbin/nscd/agents/services.c index b0a2eb99fad8..44dec39c3d25 100644 --- a/usr.sbin/nscd/agents/services.c +++ b/usr.sbin/nscd/agents/services.c @@ -145,9 +145,8 @@ services_lookup_func(const char *key, size_t key_size, char **buffer, switch (lookup_type) { case nss_lt_name: size = key_size - sizeof(enum nss_lookup_type); - name = (char *)malloc(size + 1); + name = (char *)calloc(1, size + 1); assert(name != NULL); - memset(name, 0, size + 1); memcpy(name, key + sizeof(enum nss_lookup_type), size); size2 = strlen(name) + 1; @@ -169,9 +168,8 @@ services_lookup_func(const char *key, size_t key_size, char **buffer, size = key_size - sizeof(enum nss_lookup_type) - sizeof(int); if (size > 0) { - proto = (char *)malloc(size + 1); + proto = (char *)calloc(1, size + 1); assert(proto != NULL); - memset(proto, size + 1, 0); memcpy(proto, key + sizeof(enum nss_lookup_type) + sizeof(int), size); } @@ -247,9 +245,8 @@ init_services_agent() struct common_agent *retval; TRACE_IN(init_services_agent); - retval = (struct common_agent *)malloc(sizeof(struct common_agent)); + retval = (struct common_agent *)calloc(1, sizeof(struct common_agent)); assert(retval != NULL); - memset(retval, 0, sizeof(struct common_agent)); retval->parent.name = strdup("services"); assert(retval->parent.name != NULL); @@ -267,10 +264,9 @@ init_services_mp_agent() struct multipart_agent *retval; TRACE_IN(init_services_mp_agent); - retval = (struct multipart_agent *)malloc( + retval = (struct multipart_agent *)calloc(1, sizeof(struct multipart_agent)); assert(retval != NULL); - memset(retval, 0, sizeof(struct multipart_agent)); retval->parent.name = strdup("services"); retval->parent.type = MULTIPART_AGENT; |