RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 18-Mar-2009 00:59:06 Branch: HEAD Handle: 2009031723590104 Modified files: rpm CHANGES rpm/lib poptALL.c rpmds.c rpmds.h rpmfi.c rpmfi.h rpm/rpmdb header.c header_internal.h librpmdb.vers rpm/rpmio rpmio.c rpmio_internal.h rpmurl.h url.c Log: - yarn: use the pool allocator. Summary: Revision Changes Path 1.2830 +1 -0 rpm/CHANGES 2.106 +11 -0 rpm/lib/poptALL.c 2.130 +19 -14 rpm/lib/rpmds.c 2.76 +3 -0 rpm/lib/rpmds.h 2.137 +18 -9 rpm/lib/rpmfi.c 2.69 +3 -0 rpm/lib/rpmfi.h 1.170 +22 -13 rpm/rpmdb/header.c 1.49 +4 -2 rpm/rpmdb/header_internal.h 1.56 +1 -0 rpm/rpmdb/librpmdb.vers 1.165 +24 -7 rpm/rpmio/rpmio.c 2.111 +3 -0 rpm/rpmio/rpmio_internal.h 1.36 +3 -0 rpm/rpmio/rpmurl.h 1.63 +19 -8 rpm/rpmio/url.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.2829 -r1.2830 CHANGES --- rpm/CHANGES 17 Mar 2009 22:48:55 -0000 1.2829 +++ rpm/CHANGES 17 Mar 2009 23:59:01 -0000 1.2830 @@ -1,5 +1,6 @@ 5.2a3 -> 5.2a4: + - jbj: yarn: use the pool allocator. - jbj: yarn: add a pool allocator. - devzero2000: add mkdtemp portability function to -lrpmmisc - proyvind: do lazy mkdir of %_builddir, %_rpmdir & %_srcrpmdir when doing @@ . patch -p0 <<'@@ .' Index: rpm/lib/poptALL.c ============================================================================ $ cvs diff -u -r2.105 -r2.106 poptALL.c --- rpm/lib/poptALL.c 23 Feb 2009 22:31:02 -0000 2.105 +++ rpm/lib/poptALL.c 17 Mar 2009 23:59:02 -0000 2.106 @@ -90,6 +90,8 @@ /*...@unchecked@*/ extern int _rpmds_debug; +/*...@unchecked@*/ +extern rpmioPool _rpmdsPool; /* XXX avoid -lrpmbuild linkage. */ /*...@unchecked@*/ @@ -97,6 +99,9 @@ /*...@unchecked@*/ extern int _rpmfi_debug; +/*...@unchecked@*/ +extern rpmioPool _rpmfiPool; + /*...@unchecked@*/ extern int _rpmgi_debug; @@ -446,6 +451,12 @@ /*...@globals keyids @*/ /*...@modifies keyids @*/ { + extern rpmioPool _headerPool; + + _headerPool = rpmioFreePool(_headerPool); + _rpmdsPool = rpmioFreePool(_rpmdsPool); + _rpmfiPool = rpmioFreePool(_rpmfiPool); + /* XXX this should be done in the rpmioClean() wrapper. */ /* keeps memory leak checkers quiet */ rpmFreeMacros(NULL); @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmds.c ============================================================================ $ cvs diff -u -r2.129 -r2.130 rpmds.c --- rpm/lib/rpmds.c 17 Mar 2009 13:27:46 -0000 2.129 +++ rpm/lib/rpmds.c 17 Mar 2009 23:59:02 -0000 2.130 @@ -122,6 +122,21 @@ int _rpmds_unspecified_epoch_noise = 0; /*...@=exportheadervar@*/ +/*...@unchecked@*/ /*...@null@*/ +rpmioPool _rpmdsPool; + +static rpmds rpmdsGetPool(/*...@null@*/ rpmioPool pool) + /*...@modifies pool @*/ +{ + rpmds ds; + + if (_rpmdsPool == NULL) { + _rpmdsPool = rpmioNewPool("ds", sizeof(*ds), -1); + pool = _rpmdsPool; + } + return (rpmds) rpmioGetPool(pool, sizeof(*ds)); +} + rpmds XrpmdsUnlink(rpmds ds, const char * msg, const char * fn, unsigned ln) { if (ds == NULL) return NULL; @@ -192,8 +207,6 @@ fprintf(stderr, "--> ds %p -- %ld %s at %s:%u\n", ds, yarnPeekLock(ds->use), ds->Type, __FILE__, __LINE__); /*...@=modfilesys@*/ if (yarnPeekLock(ds->use) <= 1) { - yarnLock use = ds->use; - /*...@-modfilesys@*/ if (_rpmds_debug < 0) fprintf(stderr, "*** ds %p\t%s[%d]\n", ds, ds->Type, ds->Count); @@ -216,12 +229,7 @@ ds->exclude = mireFreeAll(ds->exclude, ds->nexclude); ds->include = mireFreeAll(ds->include, ds->ninclude); - /*...@-refcounttrans -userelea...@*/ - memset(ds, 0, sizeof(*ds)); /* XXX trash and burn */ - ds = _free(ds); - /*...@=refcounttrans =userelea...@*/ - yarnTwist(use, BY, -1); - use = yarnFreeLock(use); + ds = (rpmds) rpmioPutPool((rpmioItem)ds); } else yarnTwist(ds->use, BY, -1); return NULL; @@ -328,8 +336,7 @@ N = he->p.argv; Count = he->c; if (xx && N != NULL && Count > 0) { - ds = xcalloc(1, sizeof(*ds)); - ds->use = yarnNewLock(0); + ds = rpmdsGetPool(_rpmdsPool); ds->Type = Type; ds->h = NULL; ds->i = -1; @@ -596,8 +603,7 @@ V = _free(V); R = _free(R); - ds = xcalloc(1, sizeof(*ds)); - ds->use = yarnNewLock(0); + ds = rpmdsGetPool(NULL); ds->Type = Type; ds->tagN = tagN; ds->Count = 1; @@ -632,8 +638,7 @@ Type = rpmdsTagName(tagN); - ds = xcalloc(1, sizeof(*ds)); - ds->use = yarnNewLock(0); + ds = rpmdsGetPool(_rpmdsPool); ds->Type = Type; ds->tagN = tagN; ds->A = NULL; @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmds.h ============================================================================ $ cvs diff -u -r2.75 -r2.76 rpmds.h --- rpm/lib/rpmds.h 17 Mar 2009 13:27:46 -0000 2.75 +++ rpm/lib/rpmds.h 17 Mar 2009 23:59:02 -0000 2.76 @@ -38,6 +38,8 @@ */ struct rpmds_s { yarnLock use; /*!< use count -- return to pool when zero */ +/*...@shared@*/ /*...@null@*/ + void *pool; /*!< pool (or NULL if malloc'd) */ /*...@observer@*/ const char * Type; /*!< Tag name. */ /*...@only@*/ /*...@null@*/ @@ -122,6 +124,7 @@ /** \name RPMDS */ /*...@{*/ + /** \ingroup rpmds * Unreference a dependency set instance. * @param ds dependency set @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmfi.c ============================================================================ $ cvs diff -u -r2.136 -r2.137 rpmfi.c --- rpm/lib/rpmfi.c 17 Mar 2009 14:28:16 -0000 2.136 +++ rpm/lib/rpmfi.c 17 Mar 2009 23:59:02 -0000 2.137 @@ -54,6 +54,21 @@ /*...@unchecked@*/ int _rpmfi_debug = 0; +/*...@unchecked@*/ /*...@null@*/ +rpmioPool _rpmfiPool; + +static rpmfi rpmfiGetPool(/*...@null@*/ rpmioPool pool) + /*...@modifies pool @*/ +{ + rpmfi fi; + + if (_rpmfiPool == NULL) { + _rpmfiPool = rpmioNewPool("fi", sizeof(*fi), -1); + pool = _rpmfiPool; + } + return (rpmfi) rpmioGetPool(pool, sizeof(*fi)); +} + rpmfi XrpmfiUnlink(rpmfi fi, const char * msg, const char * fn, unsigned ln) { if (fi == NULL) return NULL; @@ -1227,7 +1242,6 @@ /*...@=modfilesys@*/ if (yarnPeekLock(fi->use) <= 1L) { - yarnLock use = fi->use; /*...@-modfilesys@*/ if (_rpmfi_debug < 0) @@ -1295,12 +1309,8 @@ fi->h = headerFree(fi->h); - /*...@-nullstate -refcounttrans -userelea...@*/ - memset(fi, 0, sizeof(*fi)); /* XXX trash and burn */ - fi = _free(fi); - /*...@=nullstate =refcounttrans =userelea...@*/ - yarnTwist(use, BY, -1); - use = yarnFreeLock(use); + fi = (rpmfi) rpmioPutPool((rpmioItem)fi); + } else yarnTwist(fi->use, BY, -1); @@ -1356,11 +1366,10 @@ goto exit; } - fi = xcalloc(1, sizeof(*fi)); + fi = rpmfiGetPool(_rpmfiPool); if (fi == NULL) /* XXX can't happen */ goto exit; - fi->use = yarnNewLock(0); fi->magic = RPMFIMAGIC; fi->Type = Type; fi->i = -1; @@ . patch -p0 <<'@@ .' Index: rpm/lib/rpmfi.h ============================================================================ $ cvs diff -u -r2.68 -r2.69 rpmfi.h --- rpm/lib/rpmfi.h 17 Mar 2009 14:28:16 -0000 2.68 +++ rpm/lib/rpmfi.h 17 Mar 2009 23:59:02 -0000 2.69 @@ -86,6 +86,9 @@ */ struct rpmfi_s { yarnLock use; /*!< use count -- return to pool when zero */ +/*...@shared@*/ /*...@null@*/ + void *pool; /*!< pool (or NULL if malloc'd) */ + int i; /*!< Current file index. */ int j; /*!< Current directory index. */ @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/header.c ============================================================================ $ cvs diff -u -r1.169 -r1.170 header.c --- rpm/rpmdb/header.c 16 Mar 2009 19:22:14 -0000 1.169 +++ rpm/rpmdb/header.c 17 Mar 2009 23:59:04 -0000 1.170 @@ -11,6 +11,7 @@ #include "system.h" #include <rpmiotypes.h> +#include <rpmio.h> /* XXX for rpmioPool et al */ #define _RPMTAG_INTERNAL #include <header_internal.h> @@ -90,6 +91,22 @@ rpmop _hdr_getops = &hdr_getops; /*...@=compmempass@*/ + +/*...@unchecked@*/ /*...@null@*/ +rpmioPool _headerPool; + +static Header headerGetPool(/*...@null@*/ rpmioPool pool) + /*...@modifies pool @*/ +{ + Header h; + + if (_headerPool == NULL) { + _headerPool = rpmioNewPool(" h", sizeof(*h), -1); + pool = _headerPool; + } + return (Header) rpmioGetPool(pool, sizeof(*h)); +} + void * headerGetStats(Header h, int opx) { rpmop op = NULL; @@ -143,8 +160,6 @@ fprintf(stderr, "--> h %p -- %ld at %s:%u\n", h, yarnPeekLock(h->use), __FILE__, __LINE__); /*...@=modfilesys@*/ if (yarnPeekLock(h->use) <= 1L) { - yarnLock use = h->use; -/*...@-usereleased@*/ if (h->index != NULL) { indexEntry entry = h->index; size_t i; @@ -176,10 +191,7 @@ (void) rpmswAdd(_hdr_getops, headerGetStats(h, 19)); } /*...@=nullstate@*/ - /*...@-refcounttrans@*/ h = _free(h); /*...@=refcounttrans@*/ - yarnTwist(use, BY, -1); - use = yarnFreeLock(use); -/*...@=usereleased@*/ + h = (Header) rpmioPutPool((rpmioItem)h); } else yarnTwist(h->use, BY, -1); return NULL; @@ -187,7 +199,7 @@ Header headerNew(void) { - Header h = xcalloc(1, sizeof(*h)); + Header h = headerGetPool(_headerPool); (void) memcpy(h->magic, header_magic, sizeof(h->magic)); h->blob = NULL; @@ -204,7 +216,6 @@ ? xcalloc(h->indexAlloced, sizeof(*h->index)) : NULL); - h->use = yarnNewLock(0); /*...@-globstate -observertrans @*/ return headerLink(h); /*...@=globstate =observertrans @*/ @@ -1048,7 +1059,7 @@ dataStart = (unsigned char *) (pe + il); dataEnd = dataStart + dl; - h = xcalloc(1, sizeof(*h)); + h = headerGetPool(_headerPool); if ((sw = headerGetStats(h, 18)) != NULL) /* RPMTS_OP_HDRLOAD */ (void) rpmswEnter(sw, 0); { unsigned char * hmagic = header_magic; @@ -1061,7 +1072,6 @@ h->indexUsed = il; h->index = xcalloc(h->indexAlloced, sizeof(*h->index)); h->flags |= HEADERFLAG_SORTED; - h->use = yarnNewLock(0);; h->startoff = 0; h->endoff = (rpmuint32_t) pvlen; h = headerLink(h); @@ -1185,9 +1195,8 @@ /*...@-usereleased@*/ if (h) { h->index = _free(h->index); - /*...@-refcounttrans@*/ - h = _free(h); - /*...@=refcounttrans@*/ + yarnPossess(h->use); + h = (Header) rpmioPutPool((rpmioItem)h); } /*...@=usereleased@*/ /*...@-refcounttrans -globst...@*/ @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/header_internal.h ============================================================================ $ cvs diff -u -r1.48 -r1.49 header_internal.h --- rpm/rpmdb/header_internal.h 16 Mar 2009 19:22:14 -0000 1.48 +++ rpm/rpmdb/header_internal.h 17 Mar 2009 23:59:04 -0000 1.49 @@ -83,8 +83,10 @@ * The Header data structure. */ struct headerToken_s { -/*...@relnull@*/ - yarnLock use; + yarnLock use; /*!< use count -- return to pool when zero */ +/*...@shared@*/ /*...@null@*/ + void *pool; /*!< pool (or NULL if malloc'd) */ + unsigned char magic[8]; /*!< Header magic. */ /*...@only@*/ /*...@null@*/ void * blob; /*!< Header region blob. */ @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/librpmdb.vers ============================================================================ $ cvs diff -u -r1.55 -r1.56 librpmdb.vers --- rpm/rpmdb/librpmdb.vers 9 Feb 2009 11:24:08 -0000 1.55 +++ rpm/rpmdb/librpmdb.vers 17 Mar 2009 23:59:04 -0000 1.56 @@ -68,6 +68,7 @@ headerNEVRA; headerNew; headerNext; + _headerPool; headerPut; headerRegenSigHeader; headerReload; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmio.c ============================================================================ $ cvs diff -u -r1.164 -r1.165 rpmio.c --- rpm/rpmio/rpmio.c 16 Mar 2009 18:24:17 -0000 1.164 +++ rpm/rpmio/rpmio.c 17 Mar 2009 23:59:05 -0000 1.165 @@ -168,6 +168,22 @@ /*...@unchecked@*/ int _dav_debug = 0; + +/*...@unchecked@*/ /*...@null@*/ +rpmioPool _fdPool; + +static FD_t fdGetPool(/*...@null@*/ rpmioPool pool) + /*...@modifies pool @*/ +{ + FD_t fd; + + if (_fdPool == NULL) { + _fdPool = rpmioNewPool("fd", sizeof(*fd), -1); + pool = _fdPool; + } + return (FD_t) rpmioGetPool(pool, sizeof(*fd)); +} + /* =============================================================== */ const char * fdbg(FD_t fd) @@ -311,7 +327,6 @@ yarnPossess(fd->use); DBGREFS(fd, (stderr, "--> fd %p -- %ld %s at %s:%u %s\n", fd, yarnPeekLock(fd->use), msg, file, line, fdbg(fd))); if (yarnPeekLock(fd->use) == 1L) { - yarnLock use = fd->use; fd->opath = _free(fd->opath); fd->stats = _free(fd->stats); for (i = fd->ndigests - 1; i >= 0; i--) { @@ -330,10 +345,7 @@ #endif fd->dig = pgpDigFree(fd->dig); /*...@=onlytrans@*/ - memset(fd, 0, sizeof(*fd)); /* XXX trash and burn */ - /*...@-refcounttrans@*/ fd = _free(fd); /*...@=refcounttrans@*/ - yarnTwist(use, BY, -1); - use = yarnFreeLock(use); + fd = (FD_t) rpmioPutPool((rpmioItem)fd); return NULL; } yarnTwist(fd->use, BY, -1); @@ -347,10 +359,9 @@ /*...@null@*/ FD_t XfdNew(const char * msg, const char * file, unsigned line) { - FD_t fd = xcalloc(1, sizeof(*fd)); + FD_t fd = fdGetPool(_fdPool); if (fd == NULL) /* XXX xmalloc never returns NULL */ return NULL; - fd->use = yarnNewLock(0); fd->flags = 0; fd->magic = FDMAGIC; fd->urlType = URL_IS_UNKNOWN; @@ -3142,6 +3153,8 @@ void rpmioClean(void) { + extern rpmioPool _urlPool; + #if defined(WITH_LUA) (void) rpmluaFree(NULL); #endif @@ -3155,6 +3168,10 @@ } #endif urlFreeCache(); + + _urlPool = rpmioFreePool(_urlPool); + _fdPool = rpmioFreePool(_fdPool); + rpmlogClose(); } @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmio_internal.h ============================================================================ $ cvs diff -u -r2.110 -r2.111 rpmio_internal.h --- rpm/rpmio/rpmio_internal.h 12 Mar 2009 20:01:32 -0000 2.110 +++ rpm/rpmio/rpmio_internal.h 17 Mar 2009 23:59:05 -0000 2.111 @@ -56,6 +56,9 @@ */ struct _FD_s { yarnLock use; /*!< use count -- return to pool when zero */ +/*...@shared@*/ /*...@null@*/ + void *pool; /*!< pool (or NULL if malloc'd) */ + int flags; #define RPMIO_DEBUG_IO 0x40000000 #define RPMIO_DEBUG_REFS 0x20000000 @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmurl.h ============================================================================ $ cvs diff -u -r1.35 -r1.36 rpmurl.h --- rpm/rpmio/rpmurl.h 16 Mar 2009 17:22:03 -0000 1.35 +++ rpm/rpmio/rpmurl.h 17 Mar 2009 23:59:05 -0000 1.36 @@ -44,6 +44,9 @@ */ struct urlinfo_s { yarnLock use; /*!< use count -- return to pool when zero */ +/*...@shared@*/ /*...@null@*/ + void *pool; /*!< pool (or NULL if malloc'd) */ + /*...@owned@*/ /*...@relnull@*/ const char * url; /*!< copy of original url */ /*...@owned@*/ /*...@relnull@*/ @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/url.c ============================================================================ $ cvs diff -u -r1.62 -r1.63 url.c --- rpm/rpmio/url.c 16 Mar 2009 17:22:03 -0000 1.62 +++ rpm/rpmio/url.c 17 Mar 2009 23:59:05 -0000 1.63 @@ -69,6 +69,21 @@ /*...@unchecked@*/ int _url_count = 0; +/*...@unchecked@*/ /*...@null@*/ +rpmioPool _urlPool; + +static urlinfo urlGetPool(/*...@null@*/ rpmioPool pool) + /*...@modifies pool @*/ +{ + urlinfo u; + + if (_urlPool == NULL) { + _urlPool = rpmioNewPool(" u", sizeof(*u), -1); + pool = _urlPool; + } + return (urlinfo) rpmioGetPool(pool, sizeof(*u)); +} + urlinfo XurlLink(urlinfo u, const char *msg, const char *file, unsigned line) { URLSANE(u); @@ -82,11 +97,10 @@ urlinfo XurlNew(const char *msg, const char *file, unsigned line) { - urlinfo u; - if ((u = xcalloc(1, sizeof(*u))) == NULL) + urlinfo u = urlGetPool(_urlPool); + if (u == NULL) /* XXX can't happen */ return NULL; memset(u, 0, sizeof(*u)); - u->use = yarnNewLock(0); u->proxyp = -1; u->port = -1; u->urltype = URL_IS_UNKNOWN; @@ -111,7 +125,6 @@ urlinfo XurlFree(urlinfo u, const char *msg, const char *file, unsigned line) { - yarnLock use; int xx; URLSANE(u); @@ -121,7 +134,6 @@ yarnTwist(u->use, BY, -1); /*...@-refcounttrans -retal...@*/ return u; /*...@=refcounttrans =retal...@*/ } - use = u->use; if (u->ctrl) { #ifndef NOTYET void * fp = fdGetFp(u->ctrl); @@ -183,9 +195,8 @@ u->proxyh = _free((void *)u->proxyh); u->use = NULL; - /*...@-refcounttrans@*/ u = _free(u); /*...@-refcounttrans@*/ - yarnTwist(use, TO, 0); - use = yarnFreeLock(use); + u = (urlinfo) rpmioPutPool((rpmioItem)u); + return NULL; } @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org