Просмотр исходного кода

Replace realloc plus error checking usage with m_realloc

Guillem Jover лет назад: 18
Родитель
Сommit
800e782e21
8 измененных файлов с 18 добавлено и 11 удалено
  1. 9 0
      ChangeLog
  2. 1 0
      debian/changelog
  3. 2 2
      dpkg-deb/build.c
  4. 1 3
      dpkg-deb/info.c
  5. 2 2
      lib/fields.c
  6. 1 1
      lib/parse.c
  7. 1 2
      lib/varbuf.c
  8. 1 1
      src/main.c

+ 9 - 0
ChangeLog

@@ -1,3 +1,12 @@
+2008-06-04  Guillem Jover  <guillem@debian.org>
+
+	* 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  <guillem@debian.org>
 
 	* lib/dpkg-db.h (varbufinit): Add a size argument, fix all callers.

+ 1 - 0
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

+ 2 - 2
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))

+ 1 - 3
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);

+ 2 - 2
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;

+ 1 - 1
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++)

+ 1 - 2
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;
 }

+ 1 - 1
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;