diff options
author | Guillem Jover <guillem@debian.org> | 2010-01-24 22:11:25 +0100 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2010-01-28 20:58:05 +0100 |
commit | e10b57f16269e731c7309a9df4797089f83522c8 (patch) | |
tree | bf1e19c51aaa3d1cb0ecf9976827ff90876bf3ec | |
parent | c6520d670008b8af1e79726e690ec35435e8672c (diff) | |
download | dpkg-e10b57f16269e731c7309a9df4797089f83522c8.tar.gz |
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.
-rw-r--r-- | dpkg-deb/info.c | 2 | ||||
-rw-r--r-- | dselect/pkglist.cc | 2 | ||||
-rw-r--r-- | lib/dpkg/buffer.c | 2 | ||||
-rw-r--r-- | lib/dpkg/dbmodify.c | 2 | ||||
-rw-r--r-- | lib/dpkg/dump.c | 4 | ||||
-rw-r--r-- | lib/dpkg/showpkg.c | 6 | ||||
-rw-r--r-- | lib/dpkg/test/t-varbuf.c | 18 | ||||
-rw-r--r-- | lib/dpkg/varbuf.c | 4 | ||||
-rw-r--r-- | lib/dpkg/varbuf.h | 14 | ||||
-rw-r--r-- | src/archives.c | 12 | ||||
-rw-r--r-- | src/configure.c | 10 | ||||
-rw-r--r-- | src/depcon.c | 4 | ||||
-rw-r--r-- | src/help.c | 4 | ||||
-rw-r--r-- | src/packages.c | 4 | ||||
-rw-r--r-- | src/processarc.c | 2 | ||||
-rw-r--r-- | src/query.c | 4 | ||||
-rw-r--r-- | src/remove.c | 4 | ||||
-rw-r--r-- | src/select.c | 4 | ||||
-rw-r--r-- | src/statcmd.c | 6 |
19 files changed, 55 insertions, 53 deletions
diff --git a/dpkg-deb/info.c b/dpkg-deb/info.c index 62a2bc861..1d47d2ed9 100644 --- a/dpkg-deb/info.c +++ b/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")); diff --git a/dselect/pkglist.cc b/dselect/pkglist.cc index 3051dd563..4c03c69fb 100644 --- a/dselect/pkglist.cc +++ b/dselect/pkglist.cc @@ -459,7 +459,7 @@ void perpackagestate::free(int recursive) { pkg->clientdata= 0; } } - relations.free(); + relations.destroy(); } } diff --git a/lib/dpkg/buffer.c b/lib/dpkg/buffer.c index e70a77400..da22d9fd0 100644 --- a/lib/dpkg/buffer.c +++ b/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; \ } diff --git a/lib/dpkg/dbmodify.c b/lib/dpkg/dbmodify.c index 396b9f776..f2a572e2a 100644 --- a/lib/dpkg/dbmodify.c +++ b/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(); diff --git a/lib/dpkg/dump.c b/lib/dpkg/dump.c index ee98c8627..eeddc696b 100644 --- a/lib/dpkg/dump.c +++ b/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); diff --git a/lib/dpkg/showpkg.c b/lib/dpkg/showpkg.c index af01e47e8..918274be1 100644 --- a/lib/dpkg/showpkg.c +++ b/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); } diff --git a/lib/dpkg/test/t-varbuf.c b/lib/dpkg/test/t-varbuf.c index 2901e6bf5..798a33a13 100644 --- a/lib/dpkg/test/t-varbuf.c +++ b/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 diff --git a/lib/dpkg/varbuf.c b/lib/dpkg/varbuf.c index 07849c6d2..4b3d7e3cf 100644 --- a/lib/dpkg/varbuf.c +++ b/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; } diff --git a/lib/dpkg/varbuf.h b/lib/dpkg/varbuf.h index 4431627d8..1107da88a 100644 --- a/lib/dpkg/varbuf.h +++ b/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 diff --git a/src/archives.c b/src/archives.c index e1b3d428e..d92851b5d 100644 --- a/src/archives.c +++ b/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; } diff --git a/src/configure.c b/src/configure.c index d49780124..aa974ccba 100644 --- a/src/configure.c +++ b/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) diff --git a/src/depcon.c b/src/depcon.c index 4f2610d31..b64e35869 100644 --- a/src/depcon.c +++ b/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 diff --git a/src/help.c b/src/help.c index 07e9dfddd..9a3bca0f0 100644 --- a/src/help.c +++ b/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; diff --git a/src/packages.c b/src/packages.c index 36d5c6cb3..d41f47fdd 100644 --- a/src/packages.c +++ b/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; } diff --git a/src/processarc.c b/src/processarc.c index e3f07cf77..8417f45cb 100644 --- a/src/processarc.c +++ b/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) { diff --git a/src/query.c b/src/query.c index ff5ba3a0d..f230216c0 100644 --- a/src/query.c +++ b/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 diff --git a/src/remove.c b/src/remove.c index bf09e1585..922932e6c 100644 --- a/src/remove.c +++ b/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) diff --git a/src/select.c b/src/select.c index e45523a24..050950bfd 100644 --- a/src/select.c +++ b/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) diff --git a/src/statcmd.c b/src/statcmd.c index 07374a4c6..6ab16e7f4 100644 --- a/src/statcmd.c +++ b/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 |