From: Guillem Jover Date: Wed, 4 Jun 2008 04:50:32 +0000 (+0300) Subject: Replace realloc plus error checking usage with m_realloc X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=800e782e21f677c1f0c6da37d730d64b6318a223;p=dpkg Replace realloc plus error checking usage with m_realloc --- diff --git a/ChangeLog b/ChangeLog index 4ebbb805..d5472875 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-06-04 Guillem Jover + + * dpkg-deb/build.c (getfi): Use m_realloc instead of realloc. + * dpkg-deb/info.c (info_spew): Likewise. + * lib/fields.c (f_dependency): Likewise. + * lib/parse.c (parsedb): Likewise. + * lib/varbuf.c (varbufextend): Likewise. + * src/main.c (commandfd): Likewise. + 2008-06-04 Guillem Jover * lib/dpkg-db.h (varbufinit): Add a size argument, fix all callers. diff --git a/debian/changelog b/debian/changelog index b47322fb..200a7b0d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,7 @@ dpkg (1.15.0) UNRELEASED; urgency=low are path names, but not on patterns. Closes: #129577 * Fix the support for passing more than one --status-fd option to dpkg. Until now only the last one was being used. + * Replace realloc plus error checking usage with m_realloc. [ Raphael Hertzog ] * Enhance dpkg-shlibdeps's error message when a library can't be found to diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c index d01856c5..e458ab46 100644 --- a/dpkg-deb/build.c +++ b/dpkg-deb/build.c @@ -104,7 +104,7 @@ static struct _finfo* getfi(const char* root, int fd) { fn = m_malloc(fnlen); } else if (fnlen < (rl + MAXFILENAME)) { fnlen = rl + MAXFILENAME; - fn=(char*)realloc(fn,fnlen); + fn = m_realloc(fn, fnlen); } i=sprintf(fn,"%s/",root); @@ -112,7 +112,7 @@ static struct _finfo* getfi(const char* root, int fd) { int res; if (i>=fnlen) { fnlen += MAXFILENAME; - fn=(char*)realloc(fn,fnlen); + fn = m_realloc(fn, fnlen); } if ((res=read(fd, (fn+i), sizeof(*fn)))<0) { if ((errno==EINTR) || (errno==EAGAIN)) diff --git a/dpkg-deb/info.c b/dpkg-deb/info.c index ee7b6214..708c90c9 100644 --- a/dpkg-deb/info.c +++ b/dpkg-deb/info.c @@ -94,9 +94,7 @@ static void info_spew(const char *debar, const char *directory, while ((component = *argv++) != NULL) { pathlen = strlen(directory) + strlen(component) + 2; - controlfile = (void *) realloc((void *) controlfile, pathlen); - if (!controlfile) - ohshite(_("realloc failed (%zu bytes)"), pathlen); + controlfile = m_realloc(controlfile, pathlen); memset(controlfile, 0, sizeof(controlfile)); strcat(controlfile, directory); diff --git a/lib/fields.c b/lib/fields.c index 76d1020c..da2f253e 100644 --- a/lib/fields.c +++ b/lib/fields.c @@ -330,7 +330,7 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp, depnamelength= p - depnamestart ; if (depnamelength >= depnameused) { depnameused= depnamelength; - depname= realloc(depname,depnamelength+1); + depname = m_realloc(depname, depnamelength + 1); } strncpy(depname, depnamestart, depnamelength); *(depname + depnamelength)= 0; @@ -421,7 +421,7 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp, "version unterminated"),fip->name,depname); if (versionlength >= versionused) { versionused= versionlength; - version= realloc(version,versionlength+1); + version = m_realloc(version, versionlength + 1); } strncpy(version, versionstart, versionlength); *(version + versionlength)= 0; diff --git a/lib/parse.c b/lib/parse.c index a1937357..6d982bb8 100644 --- a/lib/parse.c +++ b/lib/parse.c @@ -205,7 +205,7 @@ int parsedb(const char *filename, enum parsedbflags flags, fip->name && strncasecmp(fieldstart,fip->name, fieldlen); fip++, ip++); if (fip->name) { - value= realloc(value,valuelen+1); + value = m_realloc(value, valuelen + 1); memcpy(value,valuestart,valuelen); *(value+valuelen)= 0; if (*ip++) diff --git a/lib/varbuf.c b/lib/varbuf.c index 70f45117..26556e18 100644 --- a/lib/varbuf.c +++ b/lib/varbuf.c @@ -107,8 +107,7 @@ void varbufextend(struct varbuf *v) { char *newbuf; newsize= v->size + 80 + v->used; - newbuf= realloc(v->buf,newsize); - if (!newbuf) ohshite(_("failed to realloc for variable buffer")); + newbuf = m_realloc(v->buf, newsize); v->size= newsize; v->buf= newbuf; } diff --git a/src/main.c b/src/main.c index c2e294d1..61029510 100644 --- a/src/main.c +++ b/src/main.c @@ -562,7 +562,7 @@ void commandfd(const char *const *argv) { if (!argc) continue; varbufaddc(&linevb,0); printf("line=`%*s'\n",(int)linevb.used,linevb.buf); - oldargs= newargs= realloc(oldargs,sizeof(const char *) * (argc + 1)); + oldargs = newargs = m_realloc(oldargs, sizeof(const char *) * (argc + 1)); argc= 1; ptr= linevb.buf; endptr= ptr + linevb.used;