1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-10 11:35:00 -05:00

_alpm_splitdep: use malloc instead of calloc

There was only one simple to handle case where we left a field
uninitialized; set it to NULL and use malloc() instead.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-09-27 17:47:40 -05:00
parent d8fab9b441
commit 69962184bb

View File

@ -409,14 +409,14 @@ int _alpm_depcmp(alpm_pkg_t *pkg, alpm_depend_t *dep)
alpm_depend_t *_alpm_splitdep(const char *depstring) alpm_depend_t *_alpm_splitdep(const char *depstring)
{ {
alpm_depend_t *depend; alpm_depend_t *depend;
const char *ptr, *version = NULL; const char *ptr, *version;
size_t deplen; size_t deplen;
if(depstring == NULL) { if(depstring == NULL) {
return NULL; return NULL;
} }
CALLOC(depend, 1, sizeof(alpm_depend_t), return NULL); MALLOC(depend, sizeof(alpm_depend_t), return NULL);
deplen = strlen(depstring); deplen = strlen(depstring);
/* Find a version comparator if one exists. If it does, set the type and /* Find a version comparator if one exists. If it does, set the type and
@ -442,8 +442,10 @@ alpm_depend_t *_alpm_splitdep(const char *depstring)
depend->mod = ALPM_DEP_MOD_EQ; depend->mod = ALPM_DEP_MOD_EQ;
version = ptr + 1; version = ptr + 1;
} else { } else {
/* no version specified, leave version and ptr NULL */ /* no version specified, leave ptr NULL and set version to NULL */
depend->mod = ALPM_DEP_MOD_ANY; depend->mod = ALPM_DEP_MOD_ANY;
depend->version = NULL;
version = NULL;
} }
/* copy the right parts to the right places */ /* copy the right parts to the right places */