commit: acd6354c5f3b1e771bbba9cb4738c264f9e11af3 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> AuthorDate: Mon Dec 30 19:03:30 2019 +0000 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> CommitDate: Mon Dec 30 19:03:30 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=acd6354c
libq/atom: slightly improve atom_explode Use malloc iso zalloc and only clear the struct bit of the allocation. Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> TODO.md | 5 ----- libq/atom.c | 5 +++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/TODO.md b/TODO.md index f4775eb..b0bac64 100644 --- a/TODO.md +++ b/TODO.md @@ -21,17 +21,12 @@ - implement our own iniparser so we *can* be dep-free -- add applet/functionality to view latest version of package in tree - (functionality necessary for upgrade in qmerge, easy printing would - also allow to use q instead of eix from Puppet provider) - # Atoms - only 32bit values are supported for revision (-r#) - only 64bit values are supported in any individual version component foo-(1234)\_alpha(56789) - these limits should not be an issue for all practical purposes -- remove zalloc from atom explode (just initialise what needs to) - make PVR match PMS https://dev.gentoo.org/~ulm/pms/head/pms.html#x1-10800011 # qmerge diff --git a/libq/atom.c b/libq/atom.c index 6f65c8b..05b138c 100644 --- a/libq/atom.c +++ b/libq/atom.c @@ -54,8 +54,9 @@ atom_explode(const char *atom) * PVR needs 3 extra bytes for possible implicit '-r0'. */ slen = strlen(atom); len = sizeof(*ret) + (slen + 1) * sizeof(*atom) * 3 + 3; - ret = xzalloc(len); - ptr = (char*)ret; + ret = xmalloc(len); + memset(ret, '\0', sizeof(*ret)); + ptr = (char *)ret; ret->P = ptr + sizeof(*ret); ret->PVR = ret->P + slen + 1; ret->CATEGORY = ret->PVR + slen + 1 + 3;
