Sfoglia il codice sorgente

libdpkg: Rename varbuffree to varbuf_destroy

The convention is for functions named free to deallocate the contents
and the given pointer, while this one only deallocates the contents, so
we rename it to make this distinction clear.
Guillem Jover 16 anni fa
parent
commit
e10b57f162

+ 1 - 1
dpkg-deb/info.c

@@ -117,7 +117,7 @@ static void info_spew(const char *debar, const char *directory,
 	      component, directory);
     }
   }
-  varbuffree(&controlfile);
+  varbuf_destroy(&controlfile);
 
   if (re==1)
     ohshit(_("One requested control component is missing"));

+ 1 - 1
dselect/pkglist.cc

@@ -459,7 +459,7 @@ void perpackagestate::free(int recursive) {
         pkg->clientdata= 0;
       }
     }
-    relations.free();
+    relations.destroy();
   }
 }
 

+ 1 - 1
lib/dpkg/buffer.c

@@ -185,7 +185,7 @@ buffer_copy_##name(type1 n1, int typeIn, \
 	ret = buffer_copy(&read_data, &write_data, limit, v.buf); \
 	buffer_done(&read_data, &write_data); \
 \
-	varbuffree(&v); \
+	varbuf_destroy(&v); \
 \
 	return ret; \
 }

+ 1 - 1
lib/dpkg/dbmodify.c

@@ -226,7 +226,7 @@ void modstatdb_shutdown(void) {
     /* tidy up a bit, but don't worry too much about failure */
     fclose(importanttmp);
     unlink(importanttmpfile);
-    varbuffree(&uvb);
+    varbuf_destroy(&uvb);
     /* fall through */
   case msdbrw_needsuperuserlockonly:
     unlockdatabase();

+ 2 - 2
lib/dpkg/dump.c

@@ -348,7 +348,7 @@ void writerecord(FILE *file, const char *filename,
   if (fputs(vb.buf,file) < 0)
     ohshite(_("failed to write details of `%.50s' to `%.250s'"), pigp->name,
 	    filename);
-   varbuffree(&vb);
+   varbuf_destroy(&vb);
 }
 
 void writedb(const char *filename, int available, int mustsync) {
@@ -392,7 +392,7 @@ void writedb(const char *filename, int available, int mustsync) {
     varbufreset(&vb);      
   }
   iterpkgend(it);
-  varbuffree(&vb);
+  varbuf_destroy(&vb);
   if (mustsync) {
     if (fflush(file))
       ohshite(_("failed to flush %s database to '%.250s'"), which, filename);

+ 3 - 3
lib/dpkg/showpkg.c

@@ -265,8 +265,8 @@ show1package(const struct lstitem *head,
 		fputs(vb.buf, stdout);
 	}
 
-	varbuffree(&wb);
-	varbuffree(&fb);
-	varbuffree(&vb);
+	varbuf_destroy(&wb);
+	varbuf_destroy(&fb);
+	varbuf_destroy(&vb);
 }
 

+ 9 - 9
lib/dpkg/test/t-varbuf.c

@@ -33,7 +33,7 @@ test_varbuf_init(void)
 	test_pass(vb.size == 0);
 	test_pass(vb.buf == NULL);
 
-	varbuffree(&vb);
+	varbuf_destroy(&vb);
 	test_pass(vb.used == 0);
 	test_pass(vb.size == 0);
 	test_pass(vb.buf == NULL);
@@ -49,7 +49,7 @@ test_varbuf_prealloc(void)
 	test_pass(vb.size >= 10);
 	test_pass(vb.buf != NULL);
 
-	varbuffree(&vb);
+	varbuf_destroy(&vb);
 	test_pass(vb.used == 0);
 	test_pass(vb.size == 0);
 	test_pass(vb.buf == NULL);
@@ -85,7 +85,7 @@ test_varbuf_grow(void)
 	test_pass(vb.used == 10);
 	test_pass(vb.size >= 110);
 
-	varbuffree(&vb);
+	varbuf_destroy(&vb);
 }
 
 static void
@@ -105,7 +105,7 @@ test_varbuf_addbuf(void)
 	test_pass(vb.size >= vb.used);
 	test_mem(vb.buf, ==, "1234567890abcde", 15);
 
-	varbuffree(&vb);
+	varbuf_destroy(&vb);
 }
 
 static void
@@ -135,7 +135,7 @@ test_varbuf_addc(void)
 	test_pass(vb.size >= vb.used);
 	test_mem(vb.buf, ==, "abcd", 4);
 
-	varbuffree(&vb);
+	varbuf_destroy(&vb);
 }
 
 static void
@@ -155,7 +155,7 @@ test_varbuf_dupc(void)
 	test_pass(vb.size >= vb.used);
 	test_mem(vb.buf, ==, "zzzzzzzzzzyyyyy", 15);
 
-	varbuffree(&vb);
+	varbuf_destroy(&vb);
 }
 
 static void
@@ -172,7 +172,7 @@ test_varbuf_substc(void)
 	test_pass(vb.size >= vb.used);
 	test_mem(vb.buf, ==, "1234z5678z9012z", 15);
 
-	varbuffree(&vb);
+	varbuf_destroy(&vb);
 }
 
 static void
@@ -199,7 +199,7 @@ test_varbuf_printf(void)
 	test_pass(vb.size >= vb.used);
 	test_str(vb.buf, ==, "format string number 10 extra string");
 
-	varbuffree(&vb);
+	varbuf_destroy(&vb);
 }
 
 static void
@@ -220,7 +220,7 @@ test_varbuf_reset(void)
 	test_pass(vb.size >= vb.used);
 	test_mem(vb.buf, ==, "abcdefghijklmno", 15);
 
-	varbuffree(&vb);
+	varbuf_destroy(&vb);
 }
 
 static void

+ 3 - 1
lib/dpkg/varbuf.c

@@ -141,6 +141,8 @@ varbuf_detach(struct varbuf *v)
   return buf;
 }
 
-void varbuffree(struct varbuf *v) {
+void
+varbuf_destroy(struct varbuf *v)
+{
   free(v->buf); v->buf=NULL; v->size=0; v->used=0;
 }

+ 7 - 7
lib/dpkg/varbuf.h

@@ -31,14 +31,14 @@ DPKG_BEGIN_DECLS
 
 /*
  * varbufinit must be called exactly once before the use of each varbuf
- * (including before any call to varbuffree), or the variable must be
+ * (including before any call to varbuf_destroy), or the variable must be
  * initialized with VARBUF_INIT.
  *
  * However, varbufs allocated ‘static’ are properly initialised anyway and
  * do not need varbufinit; multiple consecutive calls to varbufinit before
  * any use are allowed.
  *
- * varbuffree must be called after a varbuf is finished with, if anything
+ * varbuf_destroy must be called after a varbuf is finished with, if anything
  * other than varbufinit has been done. After this you are allowed but
  * not required to call varbufinit again if you want to start using the
  * varbuf again.
@@ -54,7 +54,7 @@ struct varbuf {
 	~varbuf();
 	void init(size_t _size = 0);
 	void reset();
-	void free();
+	void destroy();
 	void operator()(int c);
 	void operator()(const char *s);
 	void terminate(void/*to shut 2.6.3 up*/);
@@ -68,7 +68,7 @@ void varbufinit(struct varbuf *v, size_t size);
 void varbuf_grow(struct varbuf *v, size_t need_size);
 char *varbuf_detach(struct varbuf *v);
 void varbufreset(struct varbuf *v);
-void varbuffree(struct varbuf *v);
+void varbuf_destroy(struct varbuf *v);
 
 void varbufaddc(struct varbuf *v, int c);
 void varbufdupc(struct varbuf *v, int c, size_t n);
@@ -91,7 +91,7 @@ varbuf::varbuf(size_t _size)
 inline
 varbuf::~varbuf()
 {
-	varbuffree(this);
+	varbuf_destroy(this);
 }
 
 inline void
@@ -107,9 +107,9 @@ varbuf::reset()
 }
 
 inline void
-varbuf::free()
+varbuf::destroy()
 {
-	varbuffree(this);
+	varbuf_destroy(this);
 }
 
 inline void

+ 6 - 6
src/archives.c

@@ -872,7 +872,7 @@ void check_breaks(struct dependency *dep, struct pkginfo *pkg,
 
   fixbydeconf = NULL;
   if (depisok(dep, &why, &fixbydeconf, 0)) {
-    varbuffree(&why);
+    varbuf_destroy(&why);
     return;
   }
 
@@ -900,7 +900,7 @@ void check_breaks(struct dependency *dep, struct pkginfo *pkg,
             pfilename, pkg->name, why.buf);
     ok= 0;
   }
-  varbuffree(&why);
+  varbuf_destroy(&why);
   if (ok > 0) return;
 
   if (force_breaks(dep->list)) {
@@ -927,8 +927,8 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
 
   fixbyrm = NULL;
   if (depisok(dep, &conflictwhy, &fixbyrm, 0)) {
-    varbuffree(&conflictwhy);
-    varbuffree(&removalwhy);
+    varbuf_destroy(&conflictwhy);
+    varbuf_destroy(&removalwhy);
     return;
   }
   if (fixbyrm) {
@@ -1008,7 +1008,7 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
 
         /* This conflict is OK - we'll remove the conflictor. */
 	conflictor[cflict_index++]= fixbyrm;
-        varbuffree(&conflictwhy); varbuffree(&removalwhy);
+        varbuf_destroy(&conflictwhy); varbuf_destroy(&removalwhy);
         fprintf(stderr, _("dpkg: yes, will remove %s in favour of %s.\n"),
                 fixbyrm->name, pkg->name);
         return;
@@ -1022,7 +1022,7 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
   if (!force_conflicts(dep->list))
     ohshit(_("conflicting packages - not installing %.250s"),pkg->name);
   warning(_("ignoring conflict, may proceed anyway!"));
-  varbuffree(&conflictwhy);
+  varbuf_destroy(&conflictwhy);
   
   return;
 }

+ 5 - 5
src/configure.c

@@ -204,8 +204,8 @@ deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff)
 	conff->hash = nfstrsave(newdisthash);
 	modstatdb_note(pkg);
 
-	varbuffree(&cdr);
-	varbuffree(&cdr2);
+	varbuf_destroy(&cdr);
+	varbuf_destroy(&cdr2);
 }
 
 /**
@@ -261,7 +261,7 @@ deferred_configure(struct pkginfo *pkg)
 
 	ok = dependencies_ok(pkg, NULL, &aemsgs);
 	if (ok == 1) {
-		varbuffree(&aemsgs);
+		varbuf_destroy(&aemsgs);
 		pkg->clientdata->istobe = itb_installnew;
 		add_to_queue(pkg);
 		return;
@@ -282,7 +282,7 @@ deferred_configure(struct pkginfo *pkg)
 		fprintf(stderr,
 		        _("dpkg: dependency problems prevent configuration of %s:\n%s"),
 		        pkg->name, aemsgs.buf);
-		varbuffree(&aemsgs);
+		varbuf_destroy(&aemsgs);
 		ohshit(_("dependency problems - leaving unconfigured"));
 	} else if (aemsgs.used) {
 		varbufaddc(&aemsgs, 0);
@@ -290,7 +290,7 @@ deferred_configure(struct pkginfo *pkg)
 		        _("dpkg: %s: dependency problems, but configuring anyway as you requested:\n%s"),
 		        pkg->name, aemsgs.buf);
 	}
-	varbuffree(&aemsgs);
+	varbuf_destroy(&aemsgs);
 	sincenothing = 0;
 
 	if (pkg->eflag & eflag_reinstreq)

+ 2 - 2
src/depcon.c

@@ -118,7 +118,7 @@ findbreakcyclerecursive(struct pkginfo *pkg, struct cyclesofarlink *sofar)
     varbufaddc(&str_pkgs, '\0');
     debug(dbg_depcondetail, "findbreakcyclerecursive %s %s", pkg->name,
           str_pkgs.buf);
-    varbuffree(&str_pkgs);
+    varbuf_destroy(&str_pkgs);
   }
   thislink.pkg= pkg;
   thislink.back= sofar;
@@ -200,7 +200,7 @@ void describedepcon(struct varbuf *addto, struct dependency *dep) {
   varbufaddc(&depstr, 0);
 
   varbufprintf(addto, fmt, dep->up->name, depstr.buf);
-  varbuffree(&depstr);
+  varbuf_destroy(&depstr);
 }
   
 bool

+ 2 - 2
src/help.c

@@ -128,7 +128,7 @@ void checkpath(void) {
     }
   }
 
-  varbuffree(&filename);
+  varbuf_destroy(&filename);
 
   if (warned)
     forcibleerr(fc_badpath,_("%d expected program(s) not found on PATH.\nNB: root's "
@@ -189,7 +189,7 @@ static const char* preexecscript(const char *path, char *const *argv) {
     }
     varbufaddc(&args, '\0');
     debug(dbg_scripts, "fork/exec %s (%s )", path, args.buf);
-    varbuffree(&args);
+    varbuf_destroy(&args);
   }
   instdirl= strlen(instdir);
   if (!instdirl) return path;

+ 2 - 2
src/packages.c

@@ -478,7 +478,7 @@ static void breaks_check_one(struct varbuf *aemsgs, int *ok,
                versiondescribe(&breaker->installed.version, vdew_nonambig),
                depmsg.buf,
                gettext(statusstrings[breaker->status]));
-  varbuffree(&depmsg);
+  varbuf_destroy(&depmsg);
 
   if (virtbroken) {
     varbufprintf(aemsgs, _("  %s (%s) provides %s.\n"),
@@ -616,7 +616,7 @@ int dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
   if (!anycannotfixbytrig && canfixbytrig)
     progress_bytrigproc = canfixbytrig;
   
-  varbuffree(&oemsgs);
+  varbuf_destroy(&oemsgs);
   debug(dbg_depcon,"ok %d msgs >>%.*s<<", ok, (int)aemsgs->used, aemsgs->buf);
   return ok;
 }

+ 1 - 1
src/processarc.c

@@ -747,7 +747,7 @@ void process_archive(const char *filename) {
 	}
       }
 
-      varbuffree(&cfilename);
+      varbuf_destroy(&cfilename);
 
       if ((namenode->flags & fnnf_old_conff)) {
 	if (sameas) {

+ 2 - 2
src/query.c

@@ -280,7 +280,7 @@ void searchfiles(const char *const *argv) {
   }
   modstatdb_shutdown();
 
-  varbuffree(&path);
+  varbuf_destroy(&path);
 }
 
 void enqperpackage(const char *const *argv) {
@@ -514,7 +514,7 @@ control_path_pkg(struct pkginfo *pkg)
   }
   pop_cleanup(ehflag_normaltidy); /* closedir */
 
-  varbuffree(&db_path);
+  varbuf_destroy(&db_path);
 }
 
 static void

+ 2 - 2
src/remove.c

@@ -111,7 +111,7 @@ void deferred_remove(struct pkginfo *pkg) {
   }
 
   if (rok == 1) {
-    varbuffree(&raemsgs);
+    varbuf_destroy(&raemsgs);
     pkg->clientdata->istobe= itb_remove;
     add_to_queue(pkg);
     return;
@@ -128,7 +128,7 @@ void deferred_remove(struct pkginfo *pkg) {
             _("dpkg: %s: dependency problems, but removing anyway as you requested:\n%s"),
             pkg->name, raemsgs.buf);
   }
-  varbuffree(&raemsgs);
+  varbuf_destroy(&raemsgs);
   sincenothing= 0;
 
   if (pkg->eflag & eflag_reinstreq)

+ 2 - 2
src/select.c

@@ -136,8 +136,8 @@ void setselections(const char *const *argv) {
   }
   if (ferror(stdin)) ohshite(_("read error on standard input"));
   modstatdb_shutdown();
-  varbuffree(&namevb);
-  varbuffree(&selvb);
+  varbuf_destroy(&namevb);
+  varbuf_destroy(&selvb);
 }
 
 void clearselections(const char *const *argv)

+ 3 - 3
src/statcmd.c

@@ -241,9 +241,9 @@ statdb_write(void)
 	if (rename(dbname_new.buf, dbname.buf))
 		ohshite(_("error installing new statoverride"));
 
-	varbuffree(&dbname);
-	varbuffree(&dbname_new);
-	varbuffree(&dbname_old);
+	varbuf_destroy(&dbname);
+	varbuf_destroy(&dbname_new);
+	varbuf_destroy(&dbname_old);
 }
 
 static int