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: 27-Jun-2016 05:05:59 Branch: rpm-5_4 Handle: 2016062703055702 Added files: (Branch: rpm-5_4) rpm/rpmio rpmmqtt.c rpmmqtt.h Modified files: (Branch: rpm-5_4) rpm CHANGES rpm/rpmio bson.h librpmio.vers macro.c mongo.c rpmasn.c rpmaug.c rpmbag.c rpmbf.c rpmct.c rpmcudf.c rpmcvs.c rpmdate.c rpmdav.c rpmdir.c rpmficl.c rpmgfs.c rpmgit.c rpmhkp.c rpmio.c rpmio.h rpmiob.c rpmjni.cc rpmlua.c rpmmg.c rpmmrb.c rpmnix.c rpmperl.c rpmpython.c rpmruby.c rpmsed.c rpmsm.c rpmsp.c rpmsquirrel.c rpmsvn.c rpmsx.c rpmsyck.c rpmsyck.h rpmtcl.c rpmtpm.c rpmxar.c set.c Log: - rpmio: add/use RPMIOPOOL_ macros where possible. Summary: Revision Changes Path 1.3501.2.504+2 -1 rpm/CHANGES 2.3.4.19 +2 -0 rpm/rpmio/bson.h 2.199.2.57 +4 -2 rpm/rpmio/librpmio.vers 2.249.2.32 +47 -214 rpm/rpmio/macro.c 2.3.4.11 +4 -18 rpm/rpmio/mongo.c 2.2.2.3 +4 -18 rpm/rpmio/rpmasn.c 1.16.4.4 +6 -21 rpm/rpmio/rpmaug.c 2.4.2.2 +3 -20 rpm/rpmio/rpmbag.c 2.10.4.4 +2 -14 rpm/rpmio/rpmbf.c 1.1.2.6 +3 -19 rpm/rpmio/rpmct.c 2.7.4.3 +3 -20 rpm/rpmio/rpmcudf.c 2.1.2.3 +3 -20 rpm/rpmio/rpmcvs.c 1.1.2.5 +2 -15 rpm/rpmio/rpmdate.c 2.119.2.21 +4 -17 rpm/rpmio/rpmdav.c 2.12.2.11 +5 -21 rpm/rpmio/rpmdir.c 2.5.2.3 +3 -18 rpm/rpmio/rpmficl.c 1.1.2.9 +2 -15 rpm/rpmio/rpmgfs.c 2.1.2.57 +6 -22 rpm/rpmio/rpmgit.c 2.20.2.16 +5 -36 rpm/rpmio/rpmhkp.c 1.230.2.32 +44 -91 rpm/rpmio/rpmio.c 1.97.2.8 +37 -0 rpm/rpmio/rpmio.h 1.11.2.5 +3 -20 rpm/rpmio/rpmiob.c 1.1.2.9 +9 -3 rpm/rpmio/rpmjni.cc 2.76.4.13 +4 -32 rpm/rpmio/rpmlua.c 2.13.4.4 +2 -14 rpm/rpmio/rpmmg.c 1.1.2.1 +42 -0 rpm/rpmio/rpmmqtt.c 1.1.2.1 +66 -0 rpm/rpmio/rpmmqtt.h 1.1.2.5 +38 -81 rpm/rpmio/rpmmrb.c 2.17.2.3 +1 -18 rpm/rpmio/rpmnix.c 2.12.2.5 +7 -36 rpm/rpmio/rpmperl.c 2.16.2.11 +5 -32 rpm/rpmio/rpmpython.c 2.16.2.5 +41 -46 rpm/rpmio/rpmruby.c 1.1.2.6 +1 -15 rpm/rpmio/rpmsed.c 2.18.2.2 +4 -19 rpm/rpmio/rpmsm.c 2.7.2.5 +3 -18 rpm/rpmio/rpmsp.c 2.6.4.8 +8 -36 rpm/rpmio/rpmsquirrel.c 2.1.2.8 +3 -20 rpm/rpmio/rpmsvn.c 2.4.4.6 +4 -21 rpm/rpmio/rpmsx.c 2.5.2.4 +45 -57 rpm/rpmio/rpmsyck.c 2.4.4.1 +25 -42 rpm/rpmio/rpmsyck.h 2.13.2.4 +47 -65 rpm/rpmio/rpmtcl.c 1.5.2.22 +1 -18 rpm/rpmio/rpmtpm.c 2.26.4.3 +3 -19 rpm/rpmio/rpmxar.c 1.1.2.14 +1 -18 rpm/rpmio/set.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.3501.2.503 -r1.3501.2.504 CHANGES --- rpm/CHANGES 25 Jun 2016 22:36:53 -0000 1.3501.2.503 +++ rpm/CHANGES 27 Jun 2016 03:05:57 -0000 1.3501.2.504 @@ -1,5 +1,6 @@ 5.4.17 -> 5.4.18: - - jbj: rpmio: install <poptIO.h> and its prerea. + - jbj: rpmio: add/use RPMIOPOOL_ macros where possible. + - jbj: rpmio: install <poptIO.h> and its prereqs. - jbj: build: sanitize public includes (with iwyu). - jbj: lib: sanitize public includes (with iwyu). - jbj: rpmdb: sanitize public includes (with iwyu). @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/bson.h ============================================================================ $ cvs diff -u -r2.3.4.18 -r2.3.4.19 bson.h --- rpm/rpmio/bson.h 25 Jun 2016 22:36:54 -0000 2.3.4.18 +++ rpm/rpmio/bson.h 27 Jun 2016 03:05:57 -0000 2.3.4.19 @@ -29,6 +29,8 @@ #include <string.h> #include <time.h> +#include <inttypes.h> + #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdocumentation" @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/librpmio.vers ============================================================================ $ cvs diff -u -r2.199.2.56 -r2.199.2.57 librpmio.vers --- rpm/rpmio/librpmio.vers 24 Jun 2016 19:34:49 -0000 2.199.2.56 +++ rpm/rpmio/librpmio.vers 27 Jun 2016 03:05:57 -0000 2.199.2.57 @@ -549,6 +549,7 @@ _rpmjs_zeal; _rpmjsI; _rpmjsPool; + _rpmjsmnPool; _rpmgsr; rpmjsIPoptTable; rpmjsNew; @@ -753,8 +754,9 @@ rpmsxMatch; rpmsxNew; rpmsxSetfilecon; - rpmSyckFree; - rpmSyckLoad; + rpmsyckFree; + rpmsyckLoad; + rpmsyckNew; _rpmtcl_debug; rpmtclNew; rpmtclRun; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/macro.c ============================================================================ $ cvs diff -u -r2.249.2.31 -r2.249.2.32 macro.c --- rpm/rpmio/macro.c 10 Apr 2016 22:13:04 -0000 2.249.2.31 +++ rpm/rpmio/macro.c 27 Jun 2016 03:05:57 -0000 2.249.2.32 @@ -1905,6 +1905,33 @@ continue; } +#define RPMIOPOOL_INTERP_RUN(XY) \ + { \ + char ** av = NULL; \ + char * script = parseEmbedded(s, (size_t)(se-s), &av); \ + rpm##XY XY = rpm##XY##New(av, _globalI); \ + const char * result = NULL; \ + \ + if (rpm##XY##Run(XY, script, &result) != RPMRC_OK) \ + rc = 1; \ + else { \ + if (result == NULL) result = \ + _FIXME_embedded_interpreter_eval_returned_null; \ + if (result != NULL && *result != '\0') { \ + size_t len = strlen(result); \ + if (len > mb->nb) \ + len = mb->nb; \ + memcpy(mb->t, result, len); \ + mb->t += len; \ + mb->nb -= len; \ + } \ + } \ + XY = rpm##XY##Free(XY); \ + av = _free(av); \ + script = _free(script); \ + s = se; \ + } + #ifdef WITH_LUA if (STREQ("lua", f, fn)) { rpmlua lua = rpmluaGetGlobalState(); @@ -1983,29 +2010,8 @@ #ifdef WITH_FICL if (STREQ("ficl", f, fn)) { - char ** av = NULL; - char * script = parseEmbedded(s, (size_t)(se-s), &av); - rpmficl ficl = rpmficlNew(av, _globalI); - const char * result = NULL; - - if (rpmficlRun(ficl, script, &result) != RPMRC_OK) - rc = 1; - else { - if (result == NULL) result = _FIXME_embedded_interpreter_eval_returned_null; - if (result != NULL && *result != '\0') { - size_t len = strlen(result); - if (len > mb->nb) - len = mb->nb; - memcpy(mb->t, result, len); - mb->t += len; - mb->nb -= len; - } - } - ficl = rpmficlFree(ficl); - av = _free(av); - script = _free(script); - s = se; - continue; + RPMIOPOOL_INTERP_RUN(ficl) + continue; } #endif @@ -2013,6 +2019,7 @@ if (STREQ("git", f, fn)) { char ** av = NULL; char * script = parseEmbedded(s, (size_t)(se-s), &av); + /* XXX rpmgitNew() takes a 3rd argument */ rpmgit git = rpmgitNew(av, _globalI, NULL); const char * result = NULL; @@ -2044,6 +2051,7 @@ rpmjs js = rpmjsNew(av, _globalI); const char * result = NULL; + /* XXX rpmjs returns malloc'd result. */ if (rpmjsRun(js, script, &result) != RPMRC_OK) rc = 1; else { @@ -2069,57 +2077,15 @@ #ifdef WITH_JNIEMBED if (STREQ("jni", f, fn) || STREQ("java", f, fn)) { - char ** av = NULL; - char * script = parseEmbedded(s, (size_t)(se-s), &av); - rpmjni jni = rpmjniNew(av, _globalI); - const char * result = NULL; - - if (rpmjniRun(jni, script, &result) != RPMRC_OK) - rc = 1; - else { - if (result == NULL) result = _FIXME_embedded_interpreter_eval_returned_null; - if (result != NULL && *result != '\0') { - size_t len = strlen(result); - if (len > mb->nb) - len = mb->nb; - memcpy(mb->t, result, len); - mb->t += len; - mb->nb -= len; - } - } - jni = rpmjniFree(jni); - av = _free(av); - script = _free(script); - s = se; - continue; + RPMIOPOOL_INTERP_RUN(jni) + continue; } #endif #ifdef WITH_MRBEMBED if (STREQ("mrb", f, fn) || STREQ("mruby", f, fn)) { - char ** av = NULL; - char * script = parseEmbedded(s, (size_t)(se-s), &av); - rpmmrb mrb = rpmmrbNew(av, _globalI); - const char * result = NULL; - - if (rpmmrbRun(mrb, script, &result) != RPMRC_OK) - rc = 1; - else { - if (result == NULL) result = _FIXME_embedded_interpreter_eval_returned_null; - if (result != NULL && *result != '\0') { - size_t len = strlen(result); - if (len > mb->nb) - len = mb->nb; - memcpy(mb->t, result, len); - mb->t += len; - mb->nb -= len; - } - } - mrb = rpmmrbFree(mrb); - av = _free(av); - script = _free(script); - s = se; - continue; + RPMIOPOOL_INTERP_RUN(mrb) + continue; } #endif @@ -2212,85 +2178,22 @@ #ifdef WITH_PERLEMBED if (STREQ("perl", f, fn)) { - char ** av = NULL; - char * script = parseEmbedded(s, (size_t)(se-s), &av); - rpmperl perl = rpmperlNew(av, _globalI); - const char * result = NULL; - - if (rpmperlRun(perl, script, &result) != RPMRC_OK) - rc = 1; - else { - if (result == NULL) result = _FIXME_embedded_interpreter_eval_returned_null; - if (result != NULL && *result != '\0') { - size_t len = strlen(result); - if (len > mb->nb) - len = mb->nb; - memcpy(mb->t, result, len); - mb->t += len; - mb->nb -= len; - } - } - perl = rpmperlFree(perl); - av = _free(av); - script = _free(script); - s = se; - continue; + RPMIOPOOL_INTERP_RUN(perl) + continue; } #endif #ifdef WITH_PYTHONEMBED if (STREQ("python", f, fn)) { - char ** av = NULL; - char * script = parseEmbedded(s, (size_t)(se-s), &av); - rpmpython python = rpmpythonNew(av, _globalI); - const char * result = NULL; - - if (rpmpythonRun(python, script, &result) != RPMRC_OK) - rc = 1; - else { - if (result == NULL) result = _FIXME_embedded_interpreter_eval_returned_null; - if (result != NULL && *result != '\0') { - size_t len = strlen(result); - if (len > mb->nb) - len = mb->nb; - memcpy(mb->t, result, len); - mb->t += len; - mb->nb -= len; - } - } - python = rpmpythonFree(python); - av = _free(av); - script = _free(script); - s = se; - continue; + RPMIOPOOL_INTERP_RUN(python) + continue; } #endif #ifdef WITH_RUBYEMBED if (STREQ("ruby", f, fn)) { - char ** av = NULL; - char * script = parseEmbedded(s, (size_t)(se-s), &av); - rpmruby ruby = rpmrubyNew(av, _globalI); - const char * result = NULL; - - if (rpmrubyRun(ruby, script, &result) != RPMRC_OK) - rc = 1; - else { - if (result == NULL) result = _FIXME_embedded_interpreter_eval_returned_null; - if (result != NULL && *result != '\0') { - size_t len = strlen(result); - if (len > mb->nb) - len = mb->nb; - memcpy(mb->t, result, len); - mb->t += len; - mb->nb -= len; - } - } - ruby = rpmrubyFree(ruby); - av = _free(av); - script = _free(script); - s = se; - continue; + RPMIOPOOL_INTERP_RUN(ruby) + continue; } #endif @@ -2339,93 +2242,23 @@ #endif #ifdef WITH_SQLITE - /* Embedded squirrel. */ if (STREQ("sql", f, fn)) { - char ** av = NULL; - char * script = parseEmbedded(s, (size_t)(se-s), &av); - rpmsql sql = rpmsqlNew(av, _globalI); - const char * result = NULL; - - if (rpmsqlRun(sql, script, &result) != RPMRC_OK) - rc = 1; - else { - if (result == NULL) result = _FIXME_embedded_interpreter_eval_returned_null; - if (result != NULL && *result != '\0') { - size_t len = strlen(result); - if (len > mb->nb) - len = mb->nb; - memcpy(mb->t, result, len); - mb->t += len; - mb->nb -= len; - } - } - sql = rpmsqlFree(sql); - av = _free(av); - script = _free(script); - s = se; - continue; + RPMIOPOOL_INTERP_RUN(sql) + continue; } #endif #ifdef WITH_SQUIRREL - /* Embedded squirrel. */ if (STREQ("squirrel", f, fn)) { - char ** av = NULL; - char * script = parseEmbedded(s, (size_t)(se-s), &av); - rpmsquirrel squirrel = rpmsquirrelNew(av, _globalI); - const char * result = NULL; - - if (rpmsquirrelRun(squirrel, script, &result) != RPMRC_OK) - rc = 1; - else { - if (result == NULL) result = _FIXME_embedded_interpreter_eval_returned_null; - if (result != NULL && *result != '\0') { - size_t len = strlen(result); - if (len > mb->nb) - len = mb->nb; - memcpy(mb->t, result, len); - mb->t += len; - mb->nb -= len; - } - } - squirrel = rpmsquirrelFree(squirrel); - av = _free(av); - script = _free(script); - s = se; - continue; + RPMIOPOOL_INTERP_RUN(squirrel) + continue; } #endif #ifdef WITH_TCL - /* Embedded tcl. */ if (STREQ("tcl", f, fn)) { - char ** av = NULL; - char * script = parseEmbedded(s, (size_t)(se-s), &av); - rpmtcl tcl = rpmtclNew(av, _globalI); - const char * result = NULL; - - if (rpmtclRun(tcl, script, &result) != RPMRC_OK) - rc = 1; - else if (result != NULL && *result != '\0') { - size_t len = strlen(result); - /* XXX tcl needs an rtrim */ - char * be = (char *)result + len; - if (be > result) be--; - while (strchr("\r\n", *be) != NULL) { - *be-- = '\0'; - len--; - } - if (len > mb->nb) - len = mb->nb; - memcpy(mb->t, result, len); - mb->t += len; - mb->nb -= len; - } - tcl = rpmtclFree(tcl); - av = _free(av); - script = _free(script); - s = se; - continue; + RPMIOPOOL_INTERP_RUN(tcl) + continue; } #endif @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/mongo.c ============================================================================ $ cvs diff -u -r2.3.4.10 -r2.3.4.11 mongo.c --- rpm/rpmio/mongo.c 27 Sep 2014 15:51:22 -0000 2.3.4.10 +++ rpm/rpmio/mongo.c 27 Jun 2016 03:05:57 -0000 2.3.4.11 @@ -33,6 +33,9 @@ #include <rpmlog.h> #include <rpmurl.h> +#define _BSON_INTERNAL +#include <bson.h> + #define _RPMMGO_INTERNAL #include <mongo.h> @@ -3563,24 +3566,7 @@ mgo->fn = _free(mgo->fn); } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmmgoPool = NULL; - -static rpmmgo rpmmgoGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmmgoPool, fileSystem @*/ - /*@modifies pool, _rpmmgoPool, fileSystem @*/ -{ - rpmmgo mgo; - - if (_rpmmgoPool == NULL) { - _rpmmgoPool = rpmioNewPool("mgo", sizeof(*mgo), -1, _rpmmgo_debug, - NULL, NULL, rpmmgoFini); - pool = _rpmmgoPool; - } - mgo = (rpmmgo) rpmioGetPool(pool, sizeof(*mgo)); - memset(((char *)mgo)+sizeof(mgo->_item), 0, sizeof(*mgo)-sizeof(mgo->_item)); - return mgo; -} +RPMIOPOOL_MODULE(mgo) rpmmgo rpmmgoNew(const char * fn, int flags) { @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmasn.c ============================================================================ $ cvs diff -u -r2.2.2.2 -r2.2.2.3 rpmasn.c --- rpm/rpmio/rpmasn.c 17 Aug 2014 14:44:16 -0000 2.2.2.2 +++ rpm/rpmio/rpmasn.c 27 Jun 2016 03:05:57 -0000 2.2.2.3 @@ -12,14 +12,12 @@ #include <rpmio.h> /* for *Pool methods */ #include <rpmlog.h> #include <rpmurl.h> + #define _RPMASN_INTERNAL #include <rpmasn.h> #include "debug.h" -/*@unchecked@*/ -int _rpmasn_debug = 0; - /*@-mustmod@*/ /* XXX splint on crack */ static void rpmasnFini(void * _asn) /*@globals fileSystem @*/ @@ -36,22 +34,10 @@ } /*@=mustmod@*/ -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmasnPool = NULL; - -static rpmasn rpmasnGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmasnPool, fileSystem @*/ - /*@modifies pool, _rpmasnPool, fileSystem @*/ -{ - rpmasn asn; +/*@unchecked@*/ +int _rpmasn_debug = 0; - if (_rpmasnPool == NULL) { - _rpmasnPool = rpmioNewPool("asn", sizeof(*asn), -1, _rpmasn_debug, - NULL, NULL, rpmasnFini); - pool = _rpmasnPool; - } - return (rpmasn) rpmioGetPool(pool, sizeof(*asn)); -} +RPMIOPOOL_MODULE(asn) rpmasn rpmasnNew(const char * fn, int flags) { @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmaug.c ============================================================================ $ cvs diff -u -r1.16.4.3 -r1.16.4.4 rpmaug.c --- rpm/rpmio/rpmaug.c 19 Apr 2016 13:04:58 -0000 1.16.4.3 +++ rpm/rpmio/rpmaug.c 27 Jun 2016 03:05:57 -0000 1.16.4.4 @@ -29,12 +29,6 @@ GENfree(rpmioP) #endif /* __cplusplus */ -/*@unchecked@*/ -int _rpmaug_debug = 0; - -/*@unchecked@*/ /*@relnull@*/ -rpmaug _rpmaugI = NULL; - /*@-mustmod@*/ /* XXX splint on crack */ static void rpmaugFini(void * _aug) /*@globals fileSystem @*/ @@ -54,22 +48,10 @@ } /*@=mustmod@*/ -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmaugPool = NULL; - -static rpmaug rpmaugGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmaugPool, fileSystem @*/ - /*@modifies pool, _rpmaugPool, fileSystem @*/ -{ - rpmaug aug; +/*@unchecked@*/ +int _rpmaug_debug = 0; - if (_rpmaugPool == NULL) { - _rpmaugPool = rpmioNewPool("aug", sizeof(*aug), -1, _rpmaug_debug, - NULL, NULL, rpmaugFini); - pool = _rpmaugPool; - } - return (rpmaug) rpmioGetPool(pool, sizeof(*aug)); -} +RPMIOPOOL_MODULE(aug) /*@unchecked@*/ static const char _root[] = "/"; @@ -151,6 +133,9 @@ return rpmaugLink(aug); } +/*@unchecked@*/ /*@relnull@*/ +rpmaug _rpmaugI = NULL; + #ifdef WITH_AUGEAS static rpmaug rpmaugI(void) /*@globals _rpmaugI @*/ @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmbag.c ============================================================================ $ cvs diff -u -r2.4.2.1 -r2.4.2.2 rpmbag.c --- rpm/rpmio/rpmbag.c 16 Apr 2012 20:53:33 -0000 2.4.2.1 +++ rpm/rpmio/rpmbag.c 27 Jun 2016 03:05:58 -0000 2.4.2.2 @@ -18,9 +18,6 @@ GENfree(rpmsdb *) #endif /* __cplusplus */ -/*@unchecked@*/ -int _rpmbag_debug = 0; - static size_t _maxnsdbp = 5; static void rpmbagFini(void * _bag) @@ -35,24 +32,10 @@ bag->flags = 0; } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmbagPool = NULL; - -static rpmbag rpmbagGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmbagPool, fileSystem @*/ - /*@modifies pool, _rpmbagPool, fileSystem @*/ -{ - rpmbag bag; +/*@unchecked@*/ +int _rpmbag_debug = 0; - if (_rpmbagPool == NULL) { - _rpmbagPool = rpmioNewPool("bag", sizeof(*bag), -1, _rpmbag_debug, - NULL, NULL, rpmbagFini); - pool = _rpmbagPool; - } - bag = (rpmbag) rpmioGetPool(pool, sizeof(*bag)); - memset(((char *)bag)+sizeof(bag->_item), 0, sizeof(*bag)-sizeof(bag->_item)); - return bag; -} +RPMIOPOOL_MODULE(bag) rpmbag rpmbagNew(const char * fn, int flags) { @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmbf.c ============================================================================ $ cvs diff -u -r2.10.4.3 -r2.10.4.4 rpmbf.c --- rpm/rpmio/rpmbf.c 25 Jun 2016 22:36:54 -0000 2.10.4.3 +++ rpm/rpmio/rpmbf.c 27 Jun 2016 03:05:58 -0000 2.10.4.4 @@ -18,8 +18,6 @@ #define _JLU3_jlu32lpair 1 #include "lookup3.c" -int _rpmbf_debug = 0; - static void rpmbfFini(void * _bf) { rpmbf bf = (rpmbf) _bf; @@ -27,19 +25,9 @@ bf->bits = PBM_FREE(bf->bits); } -rpmioPool _rpmbfPool = NULL; - -static rpmbf rpmbfGetPool(rpmioPool pool) -{ - rpmbf bf; +int _rpmbf_debug = 0; - if (_rpmbfPool == NULL) { - _rpmbfPool = rpmioNewPool("bf", sizeof(*bf), -1, _rpmbf_debug, - NULL, NULL, rpmbfFini); - pool = _rpmbfPool; - } - return (rpmbf) rpmioGetPool(pool, sizeof(*bf)); -} +RPMIOPOOL_MODULE(bf) rpmbf rpmbfNew(size_t m, size_t k, unsigned flags) { @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmct.c ============================================================================ $ cvs diff -u -r1.1.2.5 -r1.1.2.6 rpmct.c --- rpm/rpmio/rpmct.c 4 Apr 2016 03:48:10 -0000 1.1.2.5 +++ rpm/rpmio/rpmct.c 27 Jun 2016 03:05:58 -0000 1.1.2.6 @@ -42,8 +42,6 @@ #include "debug.h" -/*@unchecked@*/ -int _rpmct_debug; #define SPEW(_list) if (_rpmct_debug) fprintf _list #if !defined(MIN) /* XXX OpenIndiana needs */ @@ -991,24 +989,10 @@ } /*@=mustmod@*/ -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmctPool = NULL; +/*@unchecked@*/ +int _rpmct_debug; -static rpmct rpmctGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmctPool, fileSystem @*/ - /*@modifies pool, _rpmctPool, fileSystem @*/ -{ - rpmct ct; - - if (_rpmctPool == NULL) { - _rpmctPool = rpmioNewPool("ct", sizeof(*ct), -1, _rpmct_debug, - NULL, NULL, rpmctFini); - pool = _rpmctPool; - } - ct = (rpmct) rpmioGetPool(pool, sizeof(*ct)); - memset(((char *)ct)+sizeof(ct->_item), 0, sizeof(*ct)-sizeof(ct->_item)); - return ct; -} +RPMIOPOOL_MODULE(ct) rpmct rpmctNew(char ** argv, unsigned flags) { @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmcudf.c ============================================================================ $ cvs diff -u -r2.7.4.2 -r2.7.4.3 rpmcudf.c --- rpm/rpmio/rpmcudf.c 23 Sep 2014 18:32:12 -0000 2.7.4.2 +++ rpm/rpmio/rpmcudf.c 27 Jun 2016 03:05:58 -0000 2.7.4.3 @@ -10,9 +10,6 @@ #include "debug.h" -/*@unchecked@*/ -int _rpmcudf_debug = 0; - #ifdef NOTYET /*@unchecked@*/ /*@relnull@*/ rpmcudf _rpmcudfI = NULL; @@ -454,24 +451,10 @@ cudf->iob = NULL; } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmcudfPool; +/*@unchecked@*/ +int _rpmcudf_debug = 0; -static rpmcudf rpmcudfGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmcudfPool, fileSystem @*/ - /*@modifies pool, _rpmcudfPool, fileSystem @*/ -{ - rpmcudf cudf; - - if (_rpmcudfPool == NULL) { - _rpmcudfPool = rpmioNewPool("cudf", sizeof(*cudf), -1, _rpmcudf_debug, - NULL, NULL, rpmcudfFini); - pool = _rpmcudfPool; - } - cudf = (rpmcudf) rpmioGetPool(pool, sizeof(*cudf)); - memset(((char *)cudf)+sizeof(cudf->_item), 0, sizeof(*cudf)-sizeof(cudf->_item)); - return cudf; -} +RPMIOPOOL_MODULE(cudf) #ifdef NOTYET static rpmcudf rpmcudfI(void) @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmcvs.c ============================================================================ $ cvs diff -u -r2.1.2.2 -r2.1.2.3 rpmcvs.c --- rpm/rpmio/rpmcvs.c 9 Jul 2013 08:58:10 -0000 2.1.2.2 +++ rpm/rpmio/rpmcvs.c 27 Jun 2016 03:05:58 -0000 2.1.2.3 @@ -13,9 +13,6 @@ #include "debug.h" -/*@unchecked@*/ -int _rpmcvs_debug = 0; - static void rpmcvsFini(void * _cvs) /*@globals fileSystem @*/ /*@modifies *_cvs, fileSystem @*/ @@ -25,24 +22,10 @@ cvs->fn = _free(cvs->fn); } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmcvsPool = NULL; - -static rpmcvs rpmcvsGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmcvsPool, fileSystem @*/ - /*@modifies pool, _rpmcvsPool, fileSystem @*/ -{ - rpmcvs cvs; +/*@unchecked@*/ +int _rpmcvs_debug = 0; - if (_rpmcvsPool == NULL) { - _rpmcvsPool = rpmioNewPool("cvs", sizeof(*cvs), -1, _rpmcvs_debug, - NULL, NULL, rpmcvsFini); - pool = _rpmcvsPool; - } - cvs = (rpmcvs) rpmioGetPool(pool, sizeof(*cvs)); - memset(((char *)cvs)+sizeof(cvs->_item), 0, sizeof(*cvs)-sizeof(cvs->_item)); - return cvs; -} +RPMIOPOOL_MODULE(cvs) rpmcvs rpmcvsNew(const char * fn, int flags) { @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmdate.c ============================================================================ $ cvs diff -u -r1.1.2.4 -r1.1.2.5 rpmdate.c --- rpm/rpmio/rpmdate.c 29 Mar 2016 16:40:31 -0000 1.1.2.4 +++ rpm/rpmio/rpmdate.c 27 Jun 2016 03:05:58 -0000 1.1.2.5 @@ -36,7 +36,6 @@ #endif #endif -int _rpmdate_debug = 0; #define SPEW(_list) if (_rpmdate_debug) fprintf _list static rpmRC @@ -271,21 +270,9 @@ date->results = argvFree(date->results); } -rpmioPool _rpmdatePool = NULL; - -static rpmdate rpmdateGetPool(rpmioPool pool) -{ - rpmdate date; +int _rpmdate_debug = 0; - if (_rpmdatePool == NULL) { - _rpmdatePool = rpmioNewPool("date", sizeof(*date), -1, _rpmdate_debug, - NULL, NULL, rpmdateFini); - pool = _rpmdatePool; - } - date = (rpmdate) rpmioGetPool(pool, sizeof(*date)); - memset(((char *)date)+sizeof(date->_item), 0, sizeof(*date)-sizeof(date->_item)); - return date; -} +RPMIOPOOL_MODULE(date) rpmdate rpmdateNew(char ** argv, unsigned flags) { @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmdav.c ============================================================================ $ cvs diff -u -r2.119.2.20 -r2.119.2.21 rpmdav.c --- rpm/rpmio/rpmdav.c 25 Jun 2016 07:31:08 -0000 2.119.2.20 +++ rpm/rpmio/rpmdav.c 27 Jun 2016 03:05:58 -0000 2.119.2.21 @@ -1465,8 +1465,6 @@ int _html_debug = 0; -rpmioPool _htmlPool = NULL; - #ifdef WITH_NEON struct rpmhtml_s { struct rpmioItem_s _item; /*!< usage mutex and pool identifier. */ @@ -1514,7 +1512,7 @@ #define htmlFree(_html) \ ((rpmhtml)rpmioFreePoolItem((rpmioItem)(_html), __FUNCTION__, __FILE__, __LINE__)) -static void htmlFini(void * _html) +static void rpmhtmlFini(void * _html) { rpmhtml html = (rpmhtml) _html; @@ -1530,24 +1528,13 @@ html->nb = html->nbuf = 0; } -static rpmhtml htmlGetPool(rpmioPool pool) -{ - rpmhtml html; - - if (_htmlPool == NULL) { - _htmlPool = rpmioNewPool("html", sizeof(*html), -1, _html_debug, - NULL, NULL, htmlFini); - pool = _htmlPool; - } - html = (rpmhtml) rpmioGetPool(pool, sizeof(*html)); - memset(((char *)html)+sizeof(html->_item), 0, sizeof(*html)-sizeof(html->_item)); - return html; -} +#define _rpmhtml_debug _html_debug +RPMIOPOOL_MODULE(html) static rpmhtml htmlNew(urlinfo u, rpmavx avx) { - rpmhtml html = htmlGetPool(_htmlPool); + rpmhtml html = rpmhtmlGetPool(_rpmhtmlPool); html->avx = avx; html->req = ne_request_create((ne_session *)u->sess, "GET", u->url); assert(html->req != NULL); @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmdir.c ============================================================================ $ cvs diff -u -r2.12.2.10 -r2.12.2.11 rpmdir.c --- rpm/rpmio/rpmdir.c 11 May 2015 21:10:18 -0000 2.12.2.10 +++ rpm/rpmio/rpmdir.c 27 Jun 2016 03:05:58 -0000 2.12.2.11 @@ -27,7 +27,7 @@ #endif /* __cplusplus */ /* =============================================================== */ -static void avxFini(void * _avx) +static void rpmavxFini(void * _avx) { rpmavx avx = (rpmavx) _avx; @@ -44,24 +44,8 @@ avx->resrock = NULL; } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _avxPool; - -static rpmavx avxGetPool(/*@null@*/ rpmioPool pool) - /*@globals _avxPool, fileSystem @*/ - /*@modifies pool, _avxPool, fileSystem @*/ -{ - rpmavx avx; - - if (_avxPool == NULL) { - _avxPool = rpmioNewPool("avx", sizeof(*avx), -1, _av_debug, - NULL, NULL, avxFini); - pool = _avxPool; - } - avx = (rpmavx) rpmioGetPool(pool, sizeof(*avx)); - memset(((char *)avx)+sizeof(avx->_item), 0, sizeof(*avx)-sizeof(avx->_item)); - return avx; -} +#define _rpmavx_debug _av_debug +RPMIOPOOL_MODULE(avx) void * rpmavxNew(const char *uri, struct stat *st) { @@ -73,8 +57,8 @@ return NULL; /*@=globs@*/ - avx = avxGetPool(_avxPool); - avxFini(avx); /* XXX trash-and-burn */ + avx = rpmavxGetPool(_rpmavxPool); + rpmavxFini(avx); /* XXX trash-and-burn */ /* XXX +1 byte for pesky trailing '/' */ avx->uri = strcpy((char *)xmalloc(strlen(uri) + 1 + 1), uri); @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmficl.c ============================================================================ $ cvs diff -u -r2.5.2.2 -r2.5.2.3 rpmficl.c --- rpm/rpmio/rpmficl.c 24 Sep 2014 13:03:03 -0000 2.5.2.2 +++ rpm/rpmio/rpmficl.c 27 Jun 2016 03:05:58 -0000 2.5.2.3 @@ -11,9 +11,6 @@ #include "debug.h" -/*@unchecked@*/ -int _rpmficl_debug = 0; - /*@unchecked@*/ /*@relnull@*/ rpmficl _rpmficlI = NULL; @@ -46,22 +43,10 @@ ficl->iob = NULL; } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmficlPool; +/*@unchecked@*/ +int _rpmficl_debug = 0; -static rpmficl rpmficlGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmficlPool, fileSystem @*/ - /*@modifies pool, _rpmficlPool, fileSystem @*/ -{ - rpmficl ficl; - - if (_rpmficlPool == NULL) { - _rpmficlPool = rpmioNewPool("ficl", sizeof(*ficl), -1, _rpmficl_debug, - NULL, NULL, rpmficlFini); - pool = _rpmficlPool; - } - return (rpmficl) rpmioGetPool(pool, sizeof(*ficl)); -} +RPMIOPOOL_MODULE(ficl) static rpmficl rpmficlI(void) /*@globals _rpmficlI @*/ @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmgfs.c ============================================================================ $ cvs diff -u -r1.1.2.8 -r1.1.2.9 rpmgfs.c --- rpm/rpmio/rpmgfs.c 29 Mar 2016 16:40:31 -0000 1.1.2.8 +++ rpm/rpmio/rpmgfs.c 27 Jun 2016 03:05:58 -0000 1.1.2.9 @@ -18,7 +18,6 @@ #include "debug.h" -int _rpmgfs_debug; #define SPEW(_list) if (_rpmgfs_debug) fprintf _list rpmgfs _rpmgfsI; @@ -697,21 +696,9 @@ gfs->mode = 0; } -rpmioPool _rpmgfsPool = NULL; - -static rpmgfs rpmgfsGetPool(/*@null@*/ rpmioPool pool) -{ - rpmgfs gfs; +int _rpmgfs_debug; - if (_rpmgfsPool == NULL) { - _rpmgfsPool = rpmioNewPool("gfs", sizeof(*gfs), -1, _rpmgfs_debug, - NULL, NULL, rpmgfsFini); - pool = _rpmgfsPool; - } - gfs = (rpmgfs) rpmioGetPool(pool, sizeof(*gfs)); - memset(((char *)gfs)+sizeof(gfs->_item), 0, sizeof(*gfs)-sizeof(gfs->_item)); - return gfs; -} +RPMIOPOOL_MODULE(gfs) rpmgfs rpmgfsNew(const char * fn, int flags) { @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmgit.c ============================================================================ $ cvs diff -u -r2.1.2.56 -r2.1.2.57 rpmgit.c --- rpm/rpmio/rpmgit.c 10 May 2016 17:03:41 -0000 2.1.2.56 +++ rpm/rpmio/rpmgit.c 27 Jun 2016 03:05:58 -0000 2.1.2.57 @@ -18,8 +18,6 @@ #include "debug.h" /*@unchecked@*/ -int _rpmgit_debug; -/*@unchecked@*/ const char * _rpmgit_dir; /* XXX GIT_DIR */ /*@unchecked@*/ const char * _rpmgit_tree; /* XXX GIT_WORK_TREE */ @@ -2782,27 +2780,10 @@ } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmgitPool; - -/*@unchecked@*/ /*@relnull@*/ -rpmgit _rpmgitI; - -static rpmgit rpmgitGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmgitPool, fileSystem @*/ - /*@modifies pool, _rpmgitPool, fileSystem @*/ -{ - rpmgit git; +/*@unchecked@*/ +int _rpmgit_debug; - if (_rpmgitPool == NULL) { - _rpmgitPool = rpmioNewPool("git", sizeof(*git), -1, _rpmgit_debug, - NULL, NULL, rpmgitFini); - pool = _rpmgitPool; - } - git = (rpmgit) rpmioGetPool(pool, sizeof(*git)); - memset(((char *)git)+sizeof(git->_item), 0, sizeof(*git)-sizeof(git->_item)); - return git; -} +RPMIOPOOL_MODULE(git) #ifdef NOTYET /* XXX rpmgitRun() uses pre-parsed git->av */ /*@unchecked@*/ @@ -2810,6 +2791,9 @@ "; #endif /* NOTYET */ +/*@unchecked@*/ /*@relnull@*/ +rpmgit _rpmgitI; + static rpmgit rpmgitI(void) /*@globals _rpmgitI @*/ /*@modifies _rpmgitI @*/ @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmhkp.c ============================================================================ $ cvs diff -u -r2.20.2.15 -r2.20.2.16 rpmhkp.c --- rpm/rpmio/rpmhkp.c 15 Apr 2016 18:09:59 -0000 2.20.2.15 +++ rpm/rpmio/rpmhkp.c 27 Jun 2016 03:05:58 -0000 2.20.2.16 @@ -15,12 +15,6 @@ GENfree(rpmuint8_t **) #endif /* __cplusplus */ -/*@unchecked@*/ -int _rpmhkp_debug; - -/*@unchecked@*/ /*@relnull@*/ -rpmhkp _rpmhkpI = NULL; - struct _filter_s _rpmhkp_awol = {}; struct _filter_s _rpmhkp_crl = {}; @@ -66,15 +60,6 @@ /*==============================================================*/ -static rpmhkp rpmhkpI(void) - /*@globals _rpmhkpI @*/ - /*@modifies _rpmhkpI @*/ -{ - if (_rpmhkpI == NULL) - _rpmhkpI = rpmhkpNew(NULL, 0); - return _rpmhkpI; -} - static void rpmhkpFini(void * _hkp) /*@globals fileSystem @*/ /*@modifies *_hkp, fileSystem @*/ @@ -90,29 +75,16 @@ hkp->crl = rpmbfFree(hkp->crl); } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmhkpPool; +/*@unchecked@*/ +int _rpmhkp_debug; -static rpmhkp rpmhkpGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmhkpPool, fileSystem @*/ - /*@modifies pool, _rpmhkpPool, fileSystem @*/ -{ - rpmhkp hkp; - - if (_rpmhkpPool == NULL) { - _rpmhkpPool = rpmioNewPool("hkp", sizeof(*hkp), -1, _rpmhkp_debug, - NULL, NULL, rpmhkpFini); - pool = _rpmhkpPool; - } - hkp = (rpmhkp) rpmioGetPool(pool, sizeof(*hkp)); - memset(((char *)hkp)+sizeof(hkp->_item), 0, sizeof(*hkp)-sizeof(hkp->_item)); - return hkp; -} +RPMIOPOOL_INTERP_MODULE(hkp) rpmhkp rpmhkpNew(const rpmuint8_t * keyid, uint32_t flags) { static int oneshot; - rpmhkp hkp; + rpmhkp hkp = (flags & 0x80000000) + ? rpmhkpI() : rpmhkpGetPool(_rpmhkpPool); if (!oneshot) { _rpmhkp_awol.n = 100000; @@ -128,9 +100,6 @@ oneshot++; } - /* XXX watchout for recursive call. */ - hkp = (flags & 0x80000000) ? rpmhkpI() : rpmhkpGetPool(_rpmhkpPool); - hkp->pkt = NULL; hkp->pktlen = 0; hkp->pkts = NULL; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmio.c ============================================================================ $ cvs diff -u -r1.230.2.31 -r1.230.2.32 rpmio.c --- rpm/rpmio/rpmio.c 10 May 2016 17:03:41 -0000 1.230.2.31 +++ rpm/rpmio/rpmio.c 27 Jun 2016 03:05:58 -0000 1.230.2.32 @@ -3262,58 +3262,20 @@ void rpmioClean(void) { /*@-nestedextern@*/ - extern rpmioPool _avxPool; extern rpmioPool _urlPool; - extern rpmioPool _xarPool; extern rpmioPool _digPool; - extern rpmioPool _rpmiobPool; extern rpmioPool _rpmvcPool; extern rpmioPool _rpmvtPool; /*@-shadow@*/ extern rpmioPool _mirePool; - extern rpmioPool _rpmbfPool; - extern rpmioPool _rpmhkpPool; - extern rpmioPool _htmlPool; extern rpmioPool _htPool; extern rpmioPool _cphPool; extern rpmioPool _ctxPool; - extern rpmioPool _rpmsmPool; - extern rpmioPool _rpmspPool; - extern rpmioPool _rpmsxPool; - extern rpmioPool _rpmsyckPool; /*@=shadow@*/ - extern rpmioPool _rpmasnPool; - extern rpmioPool _rpmbagPool; - extern rpmioPool _rpmctPool; - extern rpmioPool _rpmcvsPool; - extern rpmioPool _rpmdatePool; - extern rpmioPool _rpmgitPool; - extern rpmioPool _rpmsedPool; - extern rpmioPool _rpmsetPool; - extern rpmioPool _rpmsvnPool; - extern rpmioPool _rpmtpmPool; - - extern rpmioPool _rpmaugPool; - extern rpmioPool _rpmcudfPool; - extern rpmioPool _rpmficlPool; - extern rpmioPool _rpmjniPool; extern rpmioPool _rpmjsPool; - extern rpmioPool _rpmluavPool; - extern rpmioPool _rpmluaPool; - extern rpmioPool _rpmmgPool; - extern rpmioPool _rpmgfsPool; - extern rpmioPool _rpmmrbPool; -#ifdef NOTYET - extern rpmioPool _rpmnixPool; -#endif extern rpmioPool _odbcPool; - extern rpmioPool _rpmperlPool; - extern rpmioPool _rpmpythonPool; - extern rpmioPool _rpmrubyPool; extern rpmioPool _rpmsqlPool; - extern rpmioPool _rpmsquirrelPool; - extern rpmioPool _rpmtclPool; /*@=nestedextern@*/ #if defined(WITH_LUA) @@ -3338,81 +3300,72 @@ #endif urlFreeCache(); - _rpmtclI = rpmtclFree(_rpmtclI); - _rpmtclPool = rpmioFreePool(_rpmtclPool); - _rpmsquirrelI = rpmsquirrelFree(_rpmsquirrelI); - _rpmsquirrelPool = rpmioFreePool(_rpmsquirrelPool); + RPMIOPOOL_INTERP_FREE(tcl) + RPMIOPOOL_INTERP_FREE(squirrel) _rpmsqlI = rpmsqlFree(_rpmsqlI); _rpmsqlPool = rpmioFreePool(_rpmsqlPool); - _rpmrubyI = rpmrubyFree(_rpmrubyI); - _rpmrubyPool = rpmioFreePool(_rpmrubyPool); - _rpmpythonI = rpmpythonFree(_rpmpythonI); - _rpmpythonPool = rpmioFreePool(_rpmpythonPool); - _rpmperlI = rpmperlFree(_rpmperlI); - _rpmperlPool = rpmioFreePool(_rpmperlPool); - _rpmmrbI = rpmmrbFree(_rpmmrbI); - _rpmmrbPool = rpmioFreePool(_rpmmrbPool); + RPMIOPOOL_INTERP_FREE(ruby) + RPMIOPOOL_INTERP_FREE(python) + RPMIOPOOL_INTERP_FREE(perl) + RPMIOPOOL_INTERP_FREE(mrb) _rpmjsI = rpmjsFree(_rpmjsI); _rpmjsPool = rpmioFreePool(_rpmjsPool); - _rpmjniI = rpmjniFree(_rpmjniI); - _rpmjniPool = rpmioFreePool(_rpmjniPool); - _rpmficlI = rpmficlFree(_rpmficlI); - _rpmficlPool = rpmioFreePool(_rpmficlPool); - - _rpmgitI = rpmgitFree(_rpmgitI); - _rpmgitPool = rpmioFreePool(_rpmgitPool); - - _rpmaugI = rpmaugFree(_rpmaugI); - _rpmaugPool = rpmioFreePool(_rpmaugPool); - _rpmgfsI = rpmgfsFree(_rpmgfsI); - _rpmgfsPool = rpmioFreePool(_rpmgfsPool); - - _rpmasnPool = rpmioFreePool(_rpmasnPool); - _rpmbagPool = rpmioFreePool(_rpmbagPool); - _rpmctPool = rpmioFreePool(_rpmctPool); - _rpmcvsPool = rpmioFreePool(_rpmcvsPool); - _rpmdatePool = rpmioFreePool(_rpmdatePool); + RPMIOPOOL_INTERP_FREE(jni) + RPMIOPOOL_INTERP_FREE(ficl) + + RPMIOPOOL_INTERP_FREE(git) + + RPMIOPOOL_INTERP_FREE(aug) + RPMIOPOOL_INTERP_FREE(gfs) + +#ifdef NOTYET + RPMIOPOOL_FREE(mgo) + RPMIOPOOL_FREE(jsmn) +#endif + RPMIOPOOL_FREE(asn) + RPMIOPOOL_FREE(bag) + RPMIOPOOL_FREE(ct) + RPMIOPOOL_FREE(cudf) + RPMIOPOOL_FREE(cvs) + RPMIOPOOL_FREE(date) + RPMIOPOOL_FREE(mqtt) + _odbcPool = rpmioFreePool(_odbcPool); - _rpmsedPool = rpmioFreePool(_rpmsedPool); - _rpmsetPool = rpmioFreePool(_rpmsetPool); - _rpmsvnPool = rpmioFreePool(_rpmsvnPool); - _rpmtpmPool = rpmioFreePool(_rpmtpmPool); + RPMIOPOOL_FREE(sed) + RPMIOPOOL_FREE(set) + RPMIOPOOL_FREE(svn) + RPMIOPOOL_FREE(tpm) #ifdef NOTYET /* XXX FIXME: dig out the recursion deadlock. */ - _rpmnixI = rpmnixFree(_rpmnixI); - _rpmnixPool = rpmioFreePool(_rpmnixPool); + RPMIOPOOL_INTERP_FREE(nix) #endif - _rpmcudfPool = rpmioFreePool(_rpmcudfPool); - _rpmluavPool = rpmioFreePool(_rpmluavPool); - _rpmluaPool = rpmioFreePool(_rpmluaPool); + RPMIOPOOL_FREE(luav) + RPMIOPOOL_FREE(lua) - _rpmhkpI = rpmhkpFree(_rpmhkpI); - _rpmhkpPool = rpmioFreePool(_rpmhkpPool); + RPMIOPOOL_INTERP_FREE(hkp) _rpmhkp_awol.bf = rpmbfFree(_rpmhkp_awol.bf); _rpmhkp_crl.bf = rpmbfFree(_rpmhkp_crl.bf); _rpmvcPool = rpmioFreePool(_rpmvcPool); _rpmvtPool = rpmioFreePool(_rpmvtPool); - _rpmsmI = rpmsmFree(_rpmsmI); - _rpmsmPool = rpmioFreePool(_rpmsmPool); - _rpmspPool = rpmioFreePool(_rpmspPool); - _rpmsxI = rpmsxFree(_rpmsxI); - _rpmsxPool = rpmioFreePool(_rpmsxPool); + RPMIOPOOL_INTERP_FREE(sm) + RPMIOPOOL_FREE(sp) + RPMIOPOOL_INTERP_FREE(sx) - _htmlPool = rpmioFreePool(_htmlPool); + RPMIOPOOL_FREE(html) _mirePool = rpmioFreePool(_mirePool); - _rpmmgPool = rpmioFreePool(_rpmmgPool); - _rpmbfPool = rpmioFreePool(_rpmbfPool); + RPMIOPOOL_FREE(mg) + RPMIOPOOL_FREE(bf) _htPool = rpmioFreePool(_htPool); _cphPool = rpmioFreePool(_cphPool); _ctxPool = rpmioFreePool(_ctxPool); - _rpmsyckPool = rpmioFreePool(_rpmsyckPool); - _rpmiobPool = rpmioFreePool(_rpmiobPool); + RPMIOPOOL_FREE(syck) + RPMIOPOOL_FREE(iob) _digPool = rpmioFreePool(_digPool); - _xarPool = rpmioFreePool(_xarPool); - _avxPool = rpmioFreePool(_avxPool); + RPMIOPOOL_FREE(xar) + RPMIOPOOL_FREE(avx) _urlPool = rpmioFreePool(_urlPool); _fdPool = rpmioFreePool(_fdPool); @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmio.h ============================================================================ $ cvs diff -u -r1.97.2.7 -r1.97.2.8 rpmio.h --- rpm/rpmio/rpmio.h 25 Jun 2016 07:31:08 -0000 1.97.2.7 +++ rpm/rpmio/rpmio.h 27 Jun 2016 03:05:58 -0000 1.97.2.8 @@ -578,6 +578,43 @@ */ void rpmioClean(void); +#define RPMIOPOOL_MODULE(XY) \ +rpmioPool _rpm##XY##Pool; \ +static rpm##XY rpm##XY##GetPool(rpmioPool pool) \ +{ rpm##XY XY; \ + if (_rpm##XY##Pool == NULL) { \ + _rpm##XY##Pool = \ + rpmioNewPool(#XY, sizeof(*XY), -1, \ + _rpm##XY##_debug, NULL, NULL, rpm##XY##Fini); \ + pool = _rpm##XY##Pool; \ + } \ + XY = (rpm##XY) rpmioGetPool(pool, sizeof(*XY)); \ + memset(((char *)XY)+sizeof(XY->_item), 0, sizeof(*XY)-sizeof(XY->_item));\ + return XY; \ +} + +#define RPMIOPOOL_INTERP_MODULE(XY) \ +RPMIOPOOL_MODULE(XY) \ +rpm##XY _rpm##XY##I; \ +static rpm##XY rpm##XY##I(void) \ +{ \ + if (_rpm##XY##I == NULL) \ + _rpm##XY##I = rpm##XY##New(NULL, 0); \ + return _rpm##XY##I; \ +} + +#define RPMIOPOOL_FREE(XY) \ +{ extern rpmioPool _rpm##XY##Pool; \ + _rpm##XY##Pool = rpmioFreePool(_rpm##XY##Pool); \ +} + +#define RPMIOPOOL_INTERP_FREE(XY) \ +{ extern rpm##XY _rpm##XY##I; \ + extern rpmioPool _rpm##XY##Pool; \ + _rpm##XY##I = rpm##XY##Free(_rpm##XY##I); \ + _rpm##XY##Pool = rpmioFreePool(_rpm##XY##Pool); \ +} + /** * Reclaim memory pool items. * @param pool memory pool (NULL uses global rpmio pool) @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmiob.c ============================================================================ $ cvs diff -u -r1.11.2.4 -r1.11.2.5 rpmiob.c --- rpm/rpmio/rpmiob.c 13 Jul 2013 20:19:00 -0000 1.11.2.4 +++ rpm/rpmio/rpmiob.c 27 Jun 2016 03:05:58 -0000 1.11.2.5 @@ -10,36 +10,19 @@ /*@unchecked@*/ size_t _rpmiob_chunk = 1024; -/*@unchecked@*/ -int _rpmiob_debug; - static void rpmiobFini(void * _iob) { rpmiob iob = (rpmiob) _iob; -if (_rpmiob_debug) -fprintf(stderr, "--> %s(%p) %p[%u:%u]\n", __FUNCTION__, iob, iob->b, (unsigned)iob->blen, (unsigned)iob->allocated); iob->b = _free(iob->b); iob->blen = 0; iob->allocated = 0; } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmiobPool; +/*@unchecked@*/ +int _rpmiob_debug; -static rpmiob rpmiobGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmiobPool, fileSystem @*/ - /*@modifies pool, _rpmiobPool, fileSystem @*/ -{ - rpmiob iob; - - if (_rpmiobPool == NULL) { - _rpmiobPool = rpmioNewPool("iob", sizeof(*iob), -1, _rpmiob_debug, - NULL, NULL, rpmiobFini); - pool = _rpmiobPool; - } - return (rpmiob) rpmioGetPool(pool, sizeof(*iob)); -} +RPMIOPOOL_MODULE(iob) rpmiob rpmiobNew(size_t len) { @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmjni.cc ============================================================================ $ cvs diff -u -r1.1.2.8 -r1.1.2.9 rpmjni.cc --- rpm/rpmio/rpmjni.cc 28 Mar 2016 21:49:41 -0000 1.1.2.8 +++ rpm/rpmio/rpmjni.cc 27 Jun 2016 03:05:58 -0000 1.1.2.9 @@ -17,9 +17,6 @@ /*@unchecked@*/ int _rpmjni_debug; -/*@unchecked@*/ /*@relnull@*/ -rpmjni _rpmjniI = NULL; - /** * Finalizes a JNI interpreter instance/pool item */ @@ -52,6 +49,7 @@ } +#ifdef DYING /** * The pool of JNI interpreter instances * @see rpmioPool @@ -83,6 +81,9 @@ return (rpmjni) rpmioGetPool(pool, sizeof(*jni)); } +#else +RPMIOPOOL_INTERP_MODULE(jni) +#endif #if defined(WITH_JNIEMBED) /** Initializes JNI's StringIO for storing output in a string. */ @@ -93,6 +94,10 @@ "; #endif +#ifdef DYING +/*@unchecked@*/ /*@relnull@*/ +rpmjni _rpmjniI = NULL; + static rpmjni rpmjniI(void) /*@globals _rpmjniI @*/ /*@modifies _rpmjniI @*/ @@ -101,6 +106,7 @@ _rpmjniI = rpmjniNew(NULL, 0); return _rpmjniI; } +#endif #if defined(WITH_JNIEMBED) static jint JNICALL rpmjniVfprintf(FILE *fp, const char *fmt, va_list ap) @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmlua.c ============================================================================ $ cvs diff -u -r2.76.4.12 -r2.76.4.13 rpmlua.c --- rpm/rpmio/rpmlua.c 18 Sep 2014 05:07:01 -0000 2.76.4.12 +++ rpm/rpmio/rpmlua.c 27 Jun 2016 03:05:58 -0000 2.76.4.13 @@ -58,12 +58,6 @@ /*@unchecked@*/ int _rpmlua_debug = 0; -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmluaPool = NULL; - -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmluavPool = NULL; - #ifdef WITH_LUA /* XXX lua-5.2.0 retrofit destruction area. */ @@ -134,19 +128,7 @@ lua->printbuf = _free(lua->printbuf); } -static rpmlua rpmluaGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmluaPool, fileSystem @*/ - /*@modifies pool, _rpmluaPool, fileSystem @*/ -{ - rpmlua lua; - - if (_rpmluaPool == NULL) { - _rpmluaPool = rpmioNewPool("lua", sizeof(*lua), -1, _rpmlua_debug, - NULL, NULL, rpmluaFini); - pool = _rpmluaPool; - } - return (rpmlua) rpmioGetPool(pool, sizeof(*lua)); -} +RPMIOPOOL_MODULE(lua) void *rpmluaFree(rpmlua lua) { @@ -554,19 +536,9 @@ return NULL; } -static rpmluav rpmluavGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmluavPool, fileSystem @*/ - /*@modifies pool, _rpmluavPool, fileSystem @*/ -{ - rpmluav luav; - - if (_rpmluavPool == NULL) { - _rpmluavPool = rpmioNewPool("luav", sizeof(*luav), -1, _rpmlua_debug, - NULL, NULL, NULL); - pool = _rpmluavPool; - } - return (rpmluav) rpmioGetPool(pool, sizeof(*luav)); -} +#define _rpmluav_debug _rpmlua_debug +#define rpmluavFini NULL +RPMIOPOOL_MODULE(luav) rpmluav rpmluavNew(void) { @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmmg.c ============================================================================ $ cvs diff -u -r2.13.4.3 -r2.13.4.4 rpmmg.c --- rpm/rpmio/rpmmg.c 25 Jun 2016 22:36:54 -0000 2.13.4.3 +++ rpm/rpmio/rpmmg.c 27 Jun 2016 03:05:58 -0000 2.13.4.4 @@ -17,8 +17,6 @@ #include "debug.h" -int _rpmmg_debug = 0; - static void rpmmgFini(void * _mg) { rpmmg mg = (rpmmg) _mg; @@ -32,19 +30,9 @@ mg->fn = _free(mg->fn); } -rpmioPool _rpmmgPool = NULL; - -static rpmmg rpmmgGetPool(rpmioPool pool) -{ - rpmmg mg; +int _rpmmg_debug = 0; - if (_rpmmgPool == NULL) { - _rpmmgPool = rpmioNewPool("mg", sizeof(*mg), -1, _rpmmg_debug, - NULL, NULL, rpmmgFini); - pool = _rpmmgPool; - } - return (rpmmg) rpmioGetPool(pool, sizeof(*mg)); -} +RPMIOPOOL_MODULE(mg) rpmmg rpmmgNew(const char * fn, int flags) { @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmmqtt.c ============================================================================ $ cvs diff -u -r0 -r1.1.2.1 rpmmqtt.c --- /dev/null 2016-06-27 05:05:14.000000000 +0200 +++ rpmmqtt.c 2016-06-27 05:05:59.657813265 +0200 @@ -0,0 +1,42 @@ +/** \ingroup rpmio + * \file rpmio/rpmmqtt.c + */ + +#include "system.h" + +#include <rpmio.h> /* for *Pool methods */ +#include <argv.h> + +#define _RPMMQTT_INTERNAL +#include <rpmmqtt.h> + +#include "debug.h" + +static void rpmmqttFini(void * _mqtt) +{ + rpmmqtt mqtt = (rpmmqtt) _mqtt; + + if (mqtt->av) + (void) argvFree((ARGV_t)mqtt->av); + mqtt->av = NULL; + mqtt->flags = 0; +} + +int _rpmmqtt_debug = 0; + +RPMIOPOOL_MODULE(mqtt) + +rpmmqtt rpmmqttNew(char ** av, uint32_t flags) +{ + rpmmqtt mqtt = rpmmqttGetPool(_rpmmqttPool); + + mqtt->flags = flags; + mqtt->av = NULL; + if (av) { + int ac = argvCount((ARGV_t)av); + for (int i = 0; i < ac; i++) + (void) argvAdd((ARGV_t *)&mqtt->av, av[i]); + } + + return rpmmqttLink(mqtt); +} @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmmqtt.h ============================================================================ $ cvs diff -u -r0 -r1.1.2.1 rpmmqtt.h --- /dev/null 2016-06-27 05:05:14.000000000 +0200 +++ rpmmqtt.h 2016-06-27 05:05:59.666813126 +0200 @@ -0,0 +1,66 @@ +#ifndef H_RPMMQTT +#define H_RPMMQTT + +/** \ingroup rpmio + * \file rpmio/rpmmqtt.h + */ + +extern int _rpmmqtt_debug; + +typedef struct rpmmqtt_s * rpmmqtt; + +#if defined(_RPMMQTT_INTERNAL) +struct rpmmqtt_s { + struct rpmioItem_s _item; /*!< usage mutex and pool identifier. */ + char ** av; + uint32_t flags; + + int sv[2]; + +}; +#endif /* _RPMMQTT_INTERNAL */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Unreference a mqtt wrapper instance. + * @param mqtt mqtt wrapper + * @return NULL on last dereference + */ +rpmmqtt rpmmqttUnlink (rpmmqtt mqtt); +#define rpmmqttUnlink(_mqtt) \ + ((rpmmqtt)rpmioUnlinkPoolItem((rpmioItem)(_mqtt), __FUNCTION__, __FILE__, __LINE__)) + +/** + * Reference a mqtt wrapper instance. + * @param mqtt mqtt wrapper + * @return new mqtt wrapper reference + */ +rpmmqtt rpmmqttLink (rpmmqtt mqtt); +#define rpmmqttLink(_mqtt) \ + ((rpmmqtt)rpmioLinkPoolItem((rpmioItem)(_mqtt), __FUNCTION__, __FILE__, __LINE__)) + +/** + * Destroy a mqtt wrapper. + * @param mqtt mqtt wrapper + * @return NULL on last dereference + */ +rpmmqtt rpmmqttFree(rpmmqtt mqtt); +#define rpmmqttFree(_mqtt) \ + ((rpmmqtt)rpmioFreePoolItem((rpmioItem)(_mqtt), __FUNCTION__, __FILE__, __LINE__)) + +/** + * Create and load a mqtt wrapper. + * @param fn mqtt args (or NULL) + * @param flags mqtt flags + * @return new mqtt wrapper + */ +rpmmqtt rpmmqttNew(char ** av, uint32_t flags); + +#ifdef __cplusplus +} +#endif + +#endif /* H_RPMMQTT */ @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmmrb.c ============================================================================ $ cvs diff -u -r1.1.2.4 -r1.1.2.5 rpmmrb.c --- rpm/rpmio/rpmmrb.c 5 May 2016 22:27:16 -0000 1.1.2.4 +++ rpm/rpmio/rpmmrb.c 27 Jun 2016 03:05:58 -0000 1.1.2.5 @@ -17,12 +17,6 @@ #include "debug.h" -/*@unchecked@*/ -int _rpmmrb_debug = 0; - -/*@unchecked@*/ /*@relnull@*/ -rpmmrb _rpmmrbI = NULL; - /** * Finalizes a MRuby interpreter instance/pool item */ @@ -43,37 +37,10 @@ mrb->I = NULL; } -/** -* The pool of MRuby interpreter instances -* @see rpmioPool -*/ -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmmrbPool; - -/** - * Returns the current rpmio pool responsible for MRuby interpreter instances - * - * This is a wrapper function that returns the current rpmio pool responsible - * for embedded MRuby interpreters. It creates and initializes a new pool when - * there is no current pool. - * - * @return The current pool - * @see rpmioNewPool - */ -static rpmmrb rpmmrbGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmmrbPool, fileSystem @*/ - /*@modifies pool, _rpmmrbPool, fileSystem @*/ -{ - rpmmrb mrb; - - if (_rpmmrbPool == NULL) { - _rpmmrbPool = rpmioNewPool("mrb", sizeof(*mrb), -1, _rpmmrb_debug, - NULL, NULL, rpmmrbFini); - pool = _rpmmrbPool; - } +/*@unchecked@*/ +int _rpmmrb_debug = 0; - return (rpmmrb) rpmioGetPool(pool, sizeof(*mrb)); -} +RPMIOPOOL_INTERP_MODULE(mrb) #if defined(WITH_MRBEMBED) #ifdef NOTYET @@ -86,15 +53,6 @@ #endif #endif /* WITH_MRBEMBED */ -static rpmmrb rpmmrbI(void) - /*@globals _rpmmrbI @*/ - /*@modifies _rpmmrbI @*/ -{ - if (_rpmmrbI == NULL) - _rpmmrbI = rpmmrbNew(NULL, 0); - return _rpmmrbI; -} - #if defined(WITH_MRBEMBED) static void rpmmrbInfo(void) { @@ -107,57 +65,56 @@ rpmmrb rpmmrbNew(char **av, uint32_t flags) { static const char *_av[] = { "rpmmrb", NULL }; - int ac; + rpmmrb mrb = (flags & 0x80000000) + ? rpmmrbI() : rpmmrbGetPool(_rpmmrbPool); - /* XXX FIXME: recurse like every other embedded interpreter. */ - if (_rpmmrbI) - return _rpmmrbI; - - rpmmrb mrb = rpmmrbGetPool(_rpmmrbPool); - - if (av == NULL) - av = (char **) _av; - ac = argvCount((ARGV_t)av); + if (av == NULL) av = (char **) _av; #if defined(WITH_MRBEMBED) - rpmmrbInfo(); - mrb_state * I = mrb_open(); + if (mrb->I == NULL) { + static int oneshot; + mrb_state * I = mrb_open(); + int ac = argvCount((ARGV_t)av); + + if (!oneshot) { + rpmmrbInfo(); + oneshot++; + } assert(I); - mrb->I = (void *) I; + mrb->I = (void *) I; - mrb_value ARGV = mrb_ary_new_capa(I, ac); - int i; - for (i = 0; i < ac; i++) - mrb_ary_push(I, ARGV, mrb_str_new_cstr(I, av[i])); - mrb_define_global_const(I, "ARGV", ARGV); + mrb_value ARGV = mrb_ary_new_capa(I, ac); + for (int i = 0; i < ac; i++) + mrb_ary_push(I, ARGV, mrb_str_new_cstr(I, av[i])); + mrb_define_global_const(I, "ARGV", ARGV); - mrbc_context * C = mrbc_context_new(I); + mrbc_context * C = mrbc_context_new(I); assert(C); - mrb->C = (void *) C; + mrb->C = (void *) C; /* XXX -v and --version */ /* XXX --copyright */ - C->dump_result = FALSE; /* XXX -v and --verbose */ - C->no_exec = FALSE; /* XXX -c --check */ + C->dump_result = FALSE; /* XXX -v and --verbose */ + C->no_exec = FALSE; /* XXX -c --check */ - /* Set $0 */ - mrb_sym zero_sym = mrb_intern_lit(I, "$0"); + /* Set $0 */ + mrb_sym zero_sym = mrb_intern_lit(I, "$0"); #ifdef NOTYET - if (args.rfp) { /* $0 arg is a file or stdin */ - char * cmdline = args.cmdline ? args.cmdline : "-"; - mrbc_filename(I, C, cmdline); - mrb_gv_set(I, zero_sym, mrb_str_new_cstr(I, cmdline)); - } else /* $0 arg is -e */ -#endif - { - mrbc_filename(I, C, "-e"); - mrb_gv_set(I, zero_sym, mrb_str_new_lit(I, "-e")); - } + if (args.rfp) { /* $0 arg is a file or stdin */ + char * cmdline = args.cmdline ? args.cmdline : "-"; + mrbc_filename(I, C, cmdline); + mrb_gv_set(I, zero_sym, mrb_str_new_cstr(I, cmdline)); + } else /* $0 arg is -e */ +#endif + { + mrbc_filename(I, C, "-e"); + mrb_gv_set(I, zero_sym, mrb_str_new_lit(I, "-e")); + } #ifdef NOTYET - (void) rpmmrbRun(mrb, rpmmrbInitStringIO, NULL); + (void) rpmmrbRun(mrb, rpmmrbInitStringIO, NULL); #endif - + } #endif /* WITH_MRBEMBED */ return rpmmrbLink(mrb); @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmnix.c ============================================================================ $ cvs diff -u -r2.17.2.2 -r2.17.2.3 rpmnix.c --- rpm/rpmio/rpmnix.c 29 Jun 2013 16:59:11 -0000 2.17.2.2 +++ rpm/rpmio/rpmnix.c 27 Jun 2016 03:05:58 -0000 2.17.2.3 @@ -3705,24 +3705,7 @@ nix->con = NULL; } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmnixPool; - -static rpmnix rpmnixGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmnixPool, fileSystem @*/ - /*@modifies pool, _rpmnixPool, fileSystem @*/ -{ - rpmnix nix; - - if (_rpmnixPool == NULL) { - _rpmnixPool = rpmioNewPool("nix", sizeof(*nix), -1, _rpmnix_debug, - NULL, NULL, rpmnixFini); - pool = _rpmnixPool; - } - nix = (rpmnix) rpmioGetPool(pool, sizeof(*nix)); - memset(((char *)nix)+sizeof(nix->_item), 0, sizeof(*nix)-sizeof(nix->_item)); - return nix; -} +RPMIOPOOL_MODULE(nix) #ifdef NOTYET static rpmnix rpmnixI(void) @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmperl.c ============================================================================ $ cvs diff -u -r2.12.2.4 -r2.12.2.5 rpmperl.c --- rpm/rpmio/rpmperl.c 5 May 2016 22:26:51 -0000 2.12.2.4 +++ rpm/rpmio/rpmperl.c 27 Jun 2016 03:05:58 -0000 2.12.2.5 @@ -20,9 +20,6 @@ /*@unchecked@*/ int _rpmperl_debug = 0; -/*@unchecked@*/ /*@relnull@*/ -rpmperl _rpmperlI = NULL; - #define my_perl ((PerlInterpreter *)perl->I) static void rpmperlFini(void * _perl) @@ -42,22 +39,7 @@ perl->I = NULL; } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmperlPool; - -static rpmperl rpmperlGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmperlPool, fileSystem @*/ - /*@modifies pool, _rpmperlPool, fileSystem @*/ -{ - rpmperl perl; - - if (_rpmperlPool == NULL) { - _rpmperlPool = rpmioNewPool("perl", sizeof(*perl), -1, _rpmperl_debug, - NULL, NULL, rpmperlFini); - pool = _rpmperlPool; - } - return (rpmperl) rpmioGetPool(pool, sizeof(*perl)); -} +RPMIOPOOL_INTERP_MODULE(perl) #if defined(WITH_PERLEMBED) EXTERN_C void xs_init (PerlInterpreter * _my_perl PERL_UNUSED_DECL); @@ -83,15 +65,6 @@ "; #endif -static rpmperl rpmperlI(void) - /*@globals _rpmperlI @*/ - /*@modifies _rpmperlI @*/ -{ - if (_rpmperlI == NULL) - _rpmperlI = rpmperlNew(NULL, 0); - return _rpmperlI; -} - #if defined(WITH_PERLEMBED) static void rpmperlInfo(void) { @@ -103,20 +76,18 @@ rpmperl rpmperlNew(char ** av, uint32_t flags) { - rpmperl perl = -#ifdef NOTYET - (flags & 0x80000000) ? rpmperlI() : -#endif - rpmperlGetPool(_rpmperlPool); -#if defined(WITH_PERLEMBED) static const char * _av[] = { "rpmperl", NULL }; + rpmperl perl = (flags & 0x80000000) + ? rpmperlI() : rpmperlGetPool(_rpmperlPool); + + if (av == NULL) av = (char **) _av; + +#if defined(WITH_PERLEMBED) static int initialized = 0; ARGV_t argv = NULL; int argc = 0; int xx; - if (av == NULL) av = (char **) _av; - /* Build argv(argc) for the interpreter. */ xx = argvAdd(&argv, av[0]); { static const char _perlI_init[] = "%{?_perlI_init}"; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmpython.c ============================================================================ $ cvs diff -u -r2.16.2.10 -r2.16.2.11 rpmpython.c --- rpm/rpmio/rpmpython.c 7 May 2016 15:10:45 -0000 2.16.2.10 +++ rpm/rpmio/rpmpython.c 27 Jun 2016 03:05:58 -0000 2.16.2.11 @@ -20,12 +20,6 @@ #include "debug.h" -/*@unchecked@*/ -int _rpmpython_debug = 0; - -/*@unchecked@*/ /*@relnull@*/ -rpmpython _rpmpythonI = NULL; - static void rpmpythonFini(void * _python) /*@globals fileSystem @*/ /*@modifies *_python, fileSystem @*/ @@ -38,22 +32,10 @@ python->I = NULL; } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmpythonPool; - -static rpmpython rpmpythonGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmpythonPool, fileSystem @*/ - /*@modifies pool, _rpmpythonPool, fileSystem @*/ -{ - rpmpython python; +/*@unchecked@*/ +int _rpmpython_debug = 0; - if (_rpmpythonPool == NULL) { - _rpmpythonPool = rpmioNewPool("python", sizeof(*python), -1, _rpmpython_debug, - NULL, NULL, rpmpythonFini); - pool = _rpmpythonPool; - } - return (rpmpython) rpmioGetPool(pool, sizeof(*python)); -} +RPMIOPOOL_INTERP_MODULE(python) /*@unchecked@*/ #if defined(WITH_PYTHONEMBED) @@ -64,15 +46,6 @@ "; #endif -static rpmpython rpmpythonI(void) - /*@globals _rpmpythonI @*/ - /*@modifies _rpmpythonI @*/ -{ - if (_rpmpythonI == NULL) - _rpmpythonI = rpmpythonNew(NULL, 0); - return _rpmpythonI; -} - #if defined(WITH_PYTHONEMBED) static const char *pythonEnvVars[] = { "PYTHONHOME", @@ -142,7 +115,7 @@ rpmpython rpmpythonNew(char ** av, uint32_t flags) { - static char * _av[] = { (char *) "rpmpython", NULL }; + static const char * _av[] = { (char *) "rpmpython", NULL }; #if defined(WITH_PYTHONEMBED) int initialize = (!(flags & 0x80000000) || _rpmpythonI == NULL); #endif @@ -152,7 +125,7 @@ if (_rpmpython_debug) fprintf(stderr, "==> %s(%p, %d) python %p\n", __FUNCTION__, av, flags, python); - if (av == NULL) av = _av; + if (av == NULL) av = (char **) _av; #if defined(WITH_PYTHONEMBED) if (!Py_IsInitialized()) { @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmruby.c ============================================================================ $ cvs diff -u -r2.16.2.4 -r2.16.2.5 rpmruby.c --- rpm/rpmio/rpmruby.c 16 Feb 2015 21:33:12 -0000 2.16.2.4 +++ rpm/rpmio/rpmruby.c 27 Jun 2016 03:05:59 -0000 2.16.2.5 @@ -1,6 +1,7 @@ #include "system.h" #include <rpmiotypes.h> +#include <rpmlog.h> #include <argv.h> #if defined(WITH_RUBYEMBED) @@ -28,12 +29,6 @@ #include "debug.h" -/*@unchecked@*/ -int _rpmruby_debug = 0; - -/*@unchecked@*/ /*@relnull@*/ -rpmruby _rpmrubyI = NULL; - /** * Finalizes a Ruby interpreter instance/pool item */ @@ -49,37 +44,10 @@ ruby->I = NULL; } -/** -* The pool of Ruby interpreter instances -* @see rpmioPool -*/ -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmrubyPool; - -/** - * Returns the current rpmio pool responsible for Ruby interpreter instances - * - * This is a wrapper function that returns the current rpmio pool responsible - * for embedded Ruby interpreters. It creates and initializes a new pool when - * there is no current pool. - * - * @return The current pool - * @see rpmioNewPool - */ -static rpmruby rpmrubyGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmrubyPool, fileSystem @*/ - /*@modifies pool, _rpmrubyPool, fileSystem @*/ -{ - rpmruby ruby; - - if (_rpmrubyPool == NULL) { - _rpmrubyPool = rpmioNewPool("ruby", sizeof(*ruby), -1, _rpmruby_debug, - NULL, NULL, rpmrubyFini); - pool = _rpmrubyPool; - } +/*@unchecked@*/ +int _rpmruby_debug = 0; - return (rpmruby) rpmioGetPool(pool, sizeof(*ruby)); -} +RPMIOPOOL_INTERP_MODULE(ruby) #if defined(WITH_RUBYEMBED) /** Initializes Ruby's StringIO for storing output in a string. */ @@ -90,29 +58,56 @@ "; #endif -static rpmruby rpmrubyI(void) - /*@globals _rpmrubyI @*/ - /*@modifies _rpmrubyI @*/ +#if defined(WITH_RUBYEMBED) +static const char *rubyEnvVars[] = { + "RUBYLIB", + "RUBYLIB_PREFIX", + "RUBYOPT", + "RUBYPATH", + "RUBYSHELL", + NULL, +}; +static int nRubyEnvVars = sizeof(rubyEnvVars) / sizeof(rubyEnvVars[0]); + +#include <ruby/version.h> +static void rpmrubyInfo(void) { - if (_rpmrubyI == NULL) - _rpmrubyI = rpmrubyNew(NULL, 0); - return _rpmrubyI; + const char **av = rubyEnvVars; + int ac = nRubyEnvVars; + char *t; + int _lvl = RPMLOG_DEBUG; + + for (int i = 0; i < ac && av[i] != NULL; i++) { + if ((t = getenv(av[i])) == NULL) + continue; + rpmlog(_lvl, " %s=\"%s\"\n", av[i], t); + } + + rpmlog(_lvl, "==================== %s\n", ruby_description); } +#endif /* WITH_RUBYEMBED */ rpmruby rpmrubyNew(char **av, uint32_t flags) { static const char *_av[] = { "rpmruby", NULL }; + rpmruby ruby; /* XXX FIXME: recurse like every other embedded interpreter. */ if (_rpmrubyI) - return _rpmrubyI; + return _rpmrubyI; - rpmruby ruby = rpmrubyGetPool(_rpmrubyPool); + if (av == NULL) av = (char **) _av; - if (av == NULL) - av = (char **) _av; + ruby = rpmrubyGetPool(_rpmrubyPool); #if defined(WITH_RUBYEMBED) + static int oneshot; + + if (!oneshot) { + rpmrubyInfo(); + oneshot++; + } + RUBY_INIT_STACK; ruby_init(); ruby_init_loadpath(); @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmsed.c ============================================================================ $ cvs diff -u -r1.1.2.5 -r1.1.2.6 rpmsed.c --- rpm/rpmio/rpmsed.c 11 May 2015 21:10:19 -0000 1.1.2.5 +++ rpm/rpmio/rpmsed.c 27 Jun 2016 03:05:59 -0000 1.1.2.6 @@ -396,21 +396,7 @@ sed->ob = NULL; } -rpmioPool _rpmsedPool = NULL; - -static rpmsed rpmsedGetPool(/*@null@*/ rpmioPool pool) -{ - rpmsed sed; - - if (_rpmsedPool == NULL) { - _rpmsedPool = rpmioNewPool("rpmsed", sizeof(*sed), -1, _rpmsed_debug, - NULL, NULL, rpmsedFini); - pool = _rpmsedPool; - } - sed = (rpmsed) rpmioGetPool(pool, sizeof(*sed)); - memset(((char *)sed)+sizeof(sed->_item), 0, sizeof(*sed)-sizeof(sed->_item)); - return sed; -} +RPMIOPOOL_MODULE(sed) rpmsed rpmsedNew(char ** argv, unsigned flags) { @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmsm.c ============================================================================ $ cvs diff -u -r2.18.2.1 -r2.18.2.2 rpmsm.c --- rpm/rpmio/rpmsm.c 15 Apr 2012 21:20:53 -0000 2.18.2.1 +++ rpm/rpmio/rpmsm.c 27 Jun 2016 03:05:59 -0000 2.18.2.2 @@ -20,9 +20,6 @@ /*@unchecked@*/ int _rpmsm_debug = 0; -/*@unchecked@*/ /*@relnull@*/ -rpmsm _rpmsmI = NULL; - #define F_ISSET(_sm, _FLAG) (((_sm)->flags & ((RPMSM_FLAGS_##_FLAG) & ~0x40000000)) != RPMSM_FLAGS_NONE) enum rpmsmState_e { @@ -323,22 +320,7 @@ sm->I = NULL; } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmsmPool = NULL; - -static rpmsm rpmsmGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmsmPool, fileSystem @*/ - /*@modifies pool, _rpmsmPool, fileSystem @*/ -{ - rpmsm sm; - - if (_rpmsmPool == NULL) { - _rpmsmPool = rpmioNewPool("sm", sizeof(*sm), -1, _rpmsm_debug, - NULL, NULL, rpmsmFini); - pool = _rpmsmPool; - } - return (rpmsm) rpmioGetPool(pool, sizeof(*sm)); -} +RPMIOPOOL_MODULE(sm) rpmsm rpmsmNew(const char * fn, unsigned int flags) { @@ -386,6 +368,9 @@ /*@unchecked@*/ static int _rpmsmI_flags; +/*@unchecked@*/ /*@relnull@*/ +rpmsm _rpmsmI = NULL; + static rpmsm rpmsmI(void) /*@globals _rpmsmI @*/ /*@modifies _rpmsmI @*/ @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmsp.c ============================================================================ $ cvs diff -u -r2.7.2.4 -r2.7.2.5 rpmsp.c --- rpm/rpmio/rpmsp.c 30 Sep 2014 22:31:43 -0000 2.7.2.4 +++ rpm/rpmio/rpmsp.c 27 Jun 2016 03:05:59 -0000 2.7.2.5 @@ -21,9 +21,6 @@ #include "debug.h" -/*@unchecked@*/ -int _rpmsp_debug = 0; - /*@unchecked@*/ /*@relnull@*/ rpmsp _rpmspI = NULL; @@ -54,22 +51,10 @@ sp->P = NULL; } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmspPool = NULL; - -static rpmsp rpmspGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmspPool, fileSystem @*/ - /*@modifies pool, _rpmspPool, fileSystem @*/ -{ - rpmsp sp; +/*@unchecked@*/ +int _rpmsp_debug = 0; - if (_rpmspPool == NULL) { - _rpmspPool = rpmioNewPool("sp", sizeof(*sp), -1, _rpmsp_debug, - NULL, NULL, rpmspFini); - pool = _rpmspPool; - } - return (rpmsp) rpmioGetPool(pool, sizeof(*sp)); -} +RPMIOPOOL_MODULE(sp) rpmsp rpmspNew(const char * fn, unsigned int flags) { @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmsquirrel.c ============================================================================ $ cvs diff -u -r2.6.4.7 -r2.6.4.8 rpmsquirrel.c --- rpm/rpmio/rpmsquirrel.c 5 May 2016 22:26:14 -0000 2.6.4.7 +++ rpm/rpmio/rpmsquirrel.c 27 Jun 2016 03:05:59 -0000 2.6.4.8 @@ -22,12 +22,6 @@ #include "debug.h" -/*@unchecked@*/ -int _rpmsquirrel_debug; - -/*@unchecked@*/ /*@relnull@*/ -rpmsquirrel _rpmsquirrelI = NULL; - static void rpmsquirrelFini(void * _squirrel) /*@globals fileSystem @*/ /*@modifies *_squirrel, fileSystem @*/ @@ -42,22 +36,10 @@ squirrel->iob = NULL; } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmsquirrelPool; - -static rpmsquirrel rpmsquirrelGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmsquirrelPool, fileSystem @*/ - /*@modifies pool, _rpmsquirrelPool, fileSystem @*/ -{ - rpmsquirrel squirrel; +/*@unchecked@*/ +int _rpmsquirrel_debug; - if (_rpmsquirrelPool == NULL) { - _rpmsquirrelPool = rpmioNewPool("squirrel", sizeof(*squirrel), -1, _rpmsquirrel_debug, - NULL, NULL, rpmsquirrelFini); - pool = _rpmsquirrelPool; - } - return (rpmsquirrel) rpmioGetPool(pool, sizeof(*squirrel)); -} +RPMIOPOOL_INTERP_MODULE(squirrel) #if defined(WITH_SQUIRREL) static void rpmsquirrelPrint(HSQUIRRELVM v, const SQChar *s, ...) @@ -107,20 +89,13 @@ #endif /* defined(WITH_SQUIRREL) */ -static rpmsquirrel rpmsquirrelI(void) - /*@globals _rpmsquirrelI @*/ - /*@modifies _rpmsquirrelI @*/ -{ - if (_rpmsquirrelI == NULL) - _rpmsquirrelI = rpmsquirrelNew(NULL, 0); - return _rpmsquirrelI; -} - rpmsquirrel rpmsquirrelNew(char ** av, uint32_t flags) { + static const char * _av[] = { "rpmsquirrel", NULL }; rpmsquirrel squirrel = (flags & 0x80000000) - ? rpmsquirrelI() - : rpmsquirrelGetPool(_rpmsquirrelPool); + ? rpmsquirrelI() : rpmsquirrelGetPool(_rpmsquirrelPool); + + if (av == NULL) av = (char **) _av; if (squirrel->iob == NULL) squirrel->iob = rpmiobNew(0); @@ -129,16 +104,12 @@ goto exit; #if defined(WITH_SQUIRREL) - static char * _av[] = { "rpmsquirrel", NULL }; static int oneshot; SQInteger stacksize = 1024; HSQUIRRELVM v = sq_open(stacksize); int ac; int i; - if (av == NULL) av = _av; - ac = argvCount((ARGV_t)av); - if (!oneshot) { rpmsquirrelInfo(); oneshot++; @@ -180,6 +151,7 @@ /* Pass argv[argc] (using squirrelsh conventions). */ sq_pushroottable(v); sq_pushstring(v, "__argc", -1); + ac = argvCount((ARGV_t)av); sq_pushinteger(v, (SQInteger)ac); assert(!SQ_FAILED(sq_newslot(v, -3, SQFalse))); sq_pushstring(v, "__argv", -1); @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmsvn.c ============================================================================ $ cvs diff -u -r2.1.2.7 -r2.1.2.8 rpmsvn.c --- rpm/rpmio/rpmsvn.c 7 May 2016 14:51:55 -0000 2.1.2.7 +++ rpm/rpmio/rpmsvn.c 27 Jun 2016 03:05:59 -0000 2.1.2.8 @@ -29,9 +29,6 @@ #include "debug.h" -/*@unchecked@*/ -int _rpmsvn_debug = 0; - /*==============================================================*/ /*==============================================================*/ @@ -60,24 +57,10 @@ } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmsvnPool = NULL; - -static rpmsvn rpmsvnGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmsvnPool, fileSystem @*/ - /*@modifies pool, _rpmsvnPool, fileSystem @*/ -{ - rpmsvn svn; +/*@unchecked@*/ +int _rpmsvn_debug = 0; - if (_rpmsvnPool == NULL) { - _rpmsvnPool = rpmioNewPool("svn", sizeof(*svn), -1, _rpmsvn_debug, - NULL, NULL, rpmsvnFini); - pool = _rpmsvnPool; - } - svn = (rpmsvn) rpmioGetPool(pool, sizeof(*svn)); - memset(((char *)svn)+sizeof(svn->_item), 0, sizeof(*svn)-sizeof(svn->_item)); - return svn; -} +RPMIOPOOL_MODULE(svn) rpmsvn rpmsvnNew(const char * fn, int flags) { @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmsx.c ============================================================================ $ cvs diff -u -r2.4.4.5 -r2.4.4.6 rpmsx.c --- rpm/rpmio/rpmsx.c 24 Jun 2016 19:08:23 -0000 2.4.4.5 +++ rpm/rpmio/rpmsx.c 27 Jun 2016 03:05:59 -0000 2.4.4.6 @@ -57,9 +57,6 @@ #include "debug.h" -/*@unchecked@*/ -int _rpmsx_debug = 0; - #define SPEW(_list) if (_rpmsx_debug) fprintf _list static void rpmsxFini(void * _sx) @@ -69,31 +66,17 @@ rpmsx sx = (rpmsx) _sx; #if defined(WITH_SELINUX) - if (sx->fn) { -SPEW((stderr, "<-- matchpathcon_fini()\n")); + if (sx->fn) matchpathcon_fini(); - } #endif sx->flags = 0; sx->fn = _free(sx->fn); } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmsxPool = NULL; - -static rpmsx rpmsxGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmsxPool, fileSystem @*/ - /*@modifies pool, _rpmsxPool, fileSystem @*/ -{ - rpmsx sx; +/*@unchecked@*/ +int _rpmsx_debug = 0; - if (_rpmsxPool == NULL) { - _rpmsxPool = rpmioNewPool("sx", sizeof(*sx), -1, _rpmsx_debug, - NULL, NULL, rpmsxFini); - pool = _rpmsxPool; - } - return (rpmsx) rpmioGetPool(pool, sizeof(*sx)); -} +RPMIOPOOL_MODULE(sx) /*@unchecked@*/ /*@relnull@*/ rpmsx _rpmsxI = NULL; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmsyck.c ============================================================================ $ cvs diff -u -r2.5.2.3 -r2.5.2.4 rpmsyck.c --- rpm/rpmio/rpmsyck.c 4 Apr 2016 03:56:00 -0000 2.5.2.3 +++ rpm/rpmio/rpmsyck.c 27 Jun 2016 03:05:59 -0000 2.5.2.4 @@ -1,11 +1,13 @@ #include "system.h" +#include <rpmio.h> + #if defined(WITH_SYCK) #include <syck.h> -#include <rpmhash.h> -#include <rpmsyck.h> #endif -#include <rpmio.h> + +#define _RPMSYCK_INTERNAL +#include <rpmsyck.h> #include "debug.h" @@ -13,71 +15,57 @@ GENfree(rpmsyck_node) #endif /* __cplusplus */ -int _rpmsyck_debug = 0; - -rpmioPool _rpmsyckPool = NULL; - #if defined(WITH_SYCK) - -static int rpmSyckFreeNode(char *key, rpmsyck_node node, char *arg) { +static int rpmsyckFreeNode(char *key, rpmsyck_node node, char *arg) +{ switch (node->type) { - case T_STR: - node->value.key = _free(node->value.key); - break; - - case T_SEQ: - node->value.seq = _free(node->value.seq); - break; - - case T_MAP: - node->value.map = htFree(node->value.map); - break; - - default: - break; + case T_STR: + node->value.key = _free(node->value.key); + break; + case T_SEQ: + node->value.seq = _free(node->value.seq); + break; + case T_MAP: + node->value.map = htFree(node->value.map); + break; + default: + break; } node->tag = _free(node->tag); node = _free(node); return ST_CONTINUE; } +#endif /* WITH_SYCK */ -static void rsFini(void * _rpmSyck) +static void rpmsyckFini(void * _rpmsyck) { - rpmSyck rs = (rpmSyck) _rpmSyck; - if (rs->syms) { - syck_st_foreach(rs->syms, (enum st_retval (*)(const char *, const void *, void *))rpmSyckFreeNode, 0); + rpmsyck syck = (rpmsyck) _rpmsyck; +#if defined(WITH_SYCK) + if (syck->syms) { + syck_st_foreach(syck->syms, (enum st_retval (*)(const char *, const void *, void *))rpmsyckFreeNode, 0); - syck_st_free_table(rs->syms); - rs->syms = NULL; + syck_st_free_table(syck->syms); } - rs->firstNode = NULL; +#endif + syck->syms = NULL; + syck->firstNode = NULL; } -static rpmSyck rpmSyckGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmsyckPool, fileSystem @*/ - /*@modifies pool, _rpmsyckPool, fileSystem @*/ -{ - rpmSyck rs; - - if (_rpmsyckPool == NULL) { - _rpmsyckPool = rpmioNewPool("syck", sizeof(*rs), -1, _rpmsyck_debug, - NULL, NULL, rsFini); - pool = _rpmsyckPool; - } - return (rpmSyck) rpmioGetPool(pool, sizeof(*rs)); -} +int _rpmsyck_debug = 0; +RPMIOPOOL_MODULE(syck) -rpmSyck rpmSyckCreate(void) +rpmsyck rpmsyckNew(void) { - rpmSyck rs = rpmSyckGetPool(_rpmsyckPool); - rs->syms = NULL; - rs->firstNode = NULL; + rpmsyck syck = rpmsyckGetPool(_rpmsyckPool); + syck->syms = NULL; + syck->firstNode = NULL; - return (rpmSyck) rpmSyckLink(rs); + return (rpmsyck) rpmsyckLink(syck); } +#if defined(WITH_SYCK) static SYMID rpmsyck_parse_handler(SyckParser *p, SyckNode *n) { @@ -130,14 +118,15 @@ return syck_add_sym(p, (char *) node); } +#endif /* WITH_SYCK */ -rpmSyck rpmSyckLoad(char *yaml) { +rpmsyck rpmsyckLoad(char *yaml) +{ + rpmsyck syck = rpmsyckNew(); +#if defined(WITH_SYCK) SyckParser *parser; SYMID v; - rpmSyck rs; - rs = rpmSyckCreate(); - parser = syck_new_parser(); syck_parser_str_auto(parser, yaml, NULL); @@ -147,13 +136,12 @@ syck_parser_taguri_expansion(parser, 1); if((v = syck_parse(parser))) - syck_lookup_sym( parser, v, (char **)&rs->firstNode); + syck_lookup_sym( parser, v, (char **)&syck->firstNode); - rs->syms = parser->syms; + syck->syms = parser->syms; parser->syms = NULL; syck_free_parser(parser); +#endif /* WITH_SYCK */ - return rs; + return syck; } - -#endif @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmsyck.h ============================================================================ $ cvs diff -u -r2.4 -r2.4.4.1 rpmsyck.h --- rpm/rpmio/rpmsyck.h 10 Dec 2009 18:47:58 -0000 2.4 +++ rpm/rpmio/rpmsyck.h 27 Jun 2016 03:05:59 -0000 2.4.4.1 @@ -1,11 +1,10 @@ #ifndef H_RPMSYCK #define H_RPMSYCK -#if defined(WITH_SYCK) +typedef struct rpmsyck_s * rpmsyck; -#include <syck.h> +#ifdef _RPMSYCK_INTERNAL #include <rpmhash.h> - typedef enum { T_END, T_STR, @@ -13,8 +12,7 @@ T_MAP } syck_type_t; -typedef /*@abstract@*/ struct rpmsyck_node_s * rpmsyck_node; - +typedef struct rpmsyck_node_s * rpmsyck_node; struct rpmsyck_node_s { syck_type_t type; char *tag; @@ -25,66 +23,51 @@ } value; }; -typedef /*@abstract@*/ /*@refcounted@*/ struct rpmSyck_s * rpmSyck; - -struct rpmSyck_s { +struct rpmsyck_s { struct rpmioItem_s _item; /*!< usage mutex and pool identifier. */ rpmsyck_node firstNode; - st_table *syms; -#if defined(__LCLINT__) -/*@refs@*/ - int nrefs; /*!< (unused) keep splint happy */ -#endif + void * syms; /* XXX st_table * */ }; +#endif /** - * Create rpmSyck YAML document. + * Create rpmsyck YAML document. * @return pointer to initialized YAML document */ -/*@newref@*/ /*@null@*/ -rpmSyck rpmSyckCreate(void); +rpmsyck rpmsyckNew(void); /** - * Load rpmSyck YAML document from text. + * Load rpmsyck YAML document from text. * @param yaml string variable holding the YAML document as text. * @return pointer to initialized YAML document */ -/*@newref@*/ /*@null@*/ -rpmSyck rpmSyckLoad(char *yaml); +rpmsyck rpmsyckLoad(char *yaml); /** - * Unreference a rpmSyck YAML document instance. - * @param rs YAML document + * Unreference a rpmsyck YAML document instance. + * @param syck YAML document * @return NULL on last dereference */ -/*@unused@*/ /*@null@*/ -rpmSyck rpmSyckUnlink (/*@killref@*/ /*@null@*/ rpmSyck rs) - /*@modifies rs @*/; -#define rpmSyckUnlink(_rs) \ - ((rpmSyck)rpmioUnlinkPoolItem((rpmioItem)(_rs), __FUNCTION__, __FILE__, __LINE__)) +rpmsyck rpmsyckUnlink (rpmsyck syck); +#define rpmsyckUnlink(_syck) \ + ((rpmsyck)rpmioUnlinkPoolItem((rpmioItem)(_syck), __FUNCTION__, __FILE__, __LINE__)) /** - * Reference a rpmSyck YAML document instance. - * @param rs YAML document + * Reference a rpmsyck YAML document instance. + * @param syck YAML document * @return new YAML document reference */ -/*@unused@*/ /*@newref@*/ /*@null@*/ -rpmSyck rpmSyckLink (/*@null@*/ rpmSyck rs) - /*@modifies rs @*/; -#define rpmSyckLink(_rs) \ - ((rpmSyck)rpmioLinkPoolItem((rpmioItem)(_rs), __FUNCTION__, __FILE__, __LINE__)) +rpmsyck rpmsyckLink (rpmsyck syck); +#define rpmsyckLink(_syck) \ + ((rpmsyck)rpmioLinkPoolItem((rpmioItem)(_syck), __FUNCTION__, __FILE__, __LINE__)) /** - * Destroy rpmSyck YAML document. - * @param rs pointer to YAML document + * Destroy rpmsyck YAML document. + * @param syck pointer to YAML document * @return NULL on last dereference */ -/*@null@*/ -rpmSyck rpmSyckFree( /*@only@*/ rpmSyck rs) - /*@modifies rs @*/; -#define rpmSyckFree(_rs) \ - ((rpmSyck)rpmioFreePoolItem((rpmioItem)(_rs), __FUNCTION__, __FILE__, __LINE__)) - -#endif +rpmsyck rpmsyckFree(rpmsyck syck); +#define rpmsyckFree(_syck) \ + ((rpmsyck)rpmioFreePoolItem((rpmioItem)(_syck), __FUNCTION__, __FILE__, __LINE__)) #endif /* H_RPMSYCK */ @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmtcl.c ============================================================================ $ cvs diff -u -r2.13.2.3 -r2.13.2.4 rpmtcl.c --- rpm/rpmio/rpmtcl.c 5 May 2016 22:23:43 -0000 2.13.2.3 +++ rpm/rpmio/rpmtcl.c 27 Jun 2016 03:05:59 -0000 2.13.2.4 @@ -12,12 +12,6 @@ #include "debug.h" -/*@unchecked@*/ -int _rpmtcl_debug = 0; - -/*@unchecked@*/ /*@relnull@*/ -rpmtcl _rpmtclI = NULL; - static void rpmtclFini(void * _tcl) /*@globals fileSystem @*/ /*@modifies *_tcl, fileSystem @*/ @@ -32,22 +26,10 @@ tcl->iob = NULL; } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmtclPool; +/*@unchecked@*/ +int _rpmtcl_debug = 0; -static rpmtcl rpmtclGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmtclPool, fileSystem @*/ - /*@modifies pool, _rpmtclPool, fileSystem @*/ -{ - rpmtcl tcl; - - if (_rpmtclPool == NULL) { - _rpmtclPool = rpmioNewPool("tcl", sizeof(*tcl), -1, _rpmtcl_debug, - NULL, NULL, rpmtclFini); - pool = _rpmtclPool; - } - return (rpmtcl) rpmioGetPool(pool, sizeof(*tcl)); -} +RPMIOPOOL_INTERP_MODULE(tcl) #if defined(WITH_TCL) static int rpmtclIOclose(ClientData CD, Tcl_Interp *I) @@ -115,15 +97,6 @@ }; #endif -static rpmtcl rpmtclI(void) - /*@globals _rpmtclI @*/ - /*@modifies _rpmtclI @*/ -{ - if (_rpmtclI == NULL) - _rpmtclI = rpmtclNew(NULL, 0); - return _rpmtclI; -} - #if defined(WITH_TCL) static void rpmtclInfo(void) { @@ -135,42 +108,41 @@ rpmtcl rpmtclNew(char ** av, uint32_t flags) { - rpmtcl tcl = -#ifdef NOTYET - (flags & 0x80000000) ? rpmtclI() : -#endif - rpmtclGetPool(_rpmtclPool); - -#if defined(WITH_TCL) - static char * _av[] = { "rpmtcl", NULL }; - Tcl_Interp * tclI = Tcl_CreateInterp(); - char b[32]; - int ac; - static int oneshot; - - if (av == NULL) av = _av; - ac = argvCount((ARGV_t)av); - - if (!oneshot) { - rpmtclInfo(); - oneshot++; - } - - Tcl_SetVar(tclI, "argv", Tcl_Merge(ac-1, (const char *const *)av+1), TCL_GLOBAL_ONLY); - (void)sprintf(b, "%d", ac-1); - Tcl_SetVar(tclI, "argc", b, TCL_GLOBAL_ONLY); - Tcl_SetVar(tclI, "argv0", av[0], TCL_GLOBAL_ONLY); - Tcl_SetVar(tclI, "tcl_interactive", "0", TCL_GLOBAL_ONLY); - - tcl->I = tclI; - { Tcl_Channel tclout = Tcl_GetStdChannel(TCL_STDOUT); - Tcl_SetChannelOption(tclI, tclout, "-translation", "auto"); - Tcl_StackChannel(tclI, &rpmtclIO, tcl, TCL_WRITABLE, tclout); - tcl->tclout = (void *) tclout; + static const char * _av[] = { "rpmtcl", NULL }; + rpmtcl tcl = (flags & 0x80000000) + ? rpmtclI() : rpmtclGetPool(_rpmtclPool); + + if (av == NULL) av = (char **) _av; + if (tcl->iob == NULL) + tcl->iob = rpmiobNew(0); + +#if defined(WITH_TCL) + if (tcl->I == NULL) { + static int oneshot; + Tcl_Interp * tclI = Tcl_CreateInterp(); + int ac = argvCount((ARGV_t)av); + char b[32]; + + if (!oneshot) { + rpmtclInfo(); + oneshot++; + } + + Tcl_SetVar(tclI, "argv", + Tcl_Merge(ac-1, (const char *const *)av+1), TCL_GLOBAL_ONLY); + (void)sprintf(b, "%d", ac-1); + Tcl_SetVar(tclI, "argc", b, TCL_GLOBAL_ONLY); + Tcl_SetVar(tclI, "argv0", av[0], TCL_GLOBAL_ONLY); + Tcl_SetVar(tclI, "tcl_interactive", "0", TCL_GLOBAL_ONLY); + + { Tcl_Channel tclout = Tcl_GetStdChannel(TCL_STDOUT); + Tcl_SetChannelOption(tclI, tclout, "-translation", "auto"); + Tcl_StackChannel(tclI, &rpmtclIO, tcl, TCL_WRITABLE, tclout); + tcl->tclout = (void *) tclout; + } + tcl->I = tclI; } #endif - tcl->iob = rpmiobNew(0); - return rpmtclLink(tcl); } @@ -205,8 +177,18 @@ #if defined(WITH_TCL) if (str != NULL && Tcl_Eval((Tcl_Interp *)tcl->I, str) == TCL_OK) { rc = RPMRC_OK; - if (resultp) + if (resultp) { *resultp = rpmiobStr(tcl->iob); + { /* XXX tcl needs an rtrim */ + size_t len = strlen(*resultp); + char *be = (char *) (*resultp + len); + if (be > *resultp) be--; + while (strchr("\r\n", *be) != NULL) { + *be-- = '\0'; + len--; + } + } + } } #endif return rc; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmtpm.c ============================================================================ $ cvs diff -u -r1.5.2.21 -r1.5.2.22 rpmtpm.c --- rpm/rpmio/rpmtpm.c 30 Sep 2014 22:31:43 -0000 1.5.2.21 +++ rpm/rpmio/rpmtpm.c 27 Jun 2016 03:05:59 -0000 1.5.2.22 @@ -250,24 +250,7 @@ } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmtpmPool = NULL; - -static rpmtpm rpmtpmGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmtpmPool, fileSystem @*/ - /*@modifies pool, _rpmtpmPool, fileSystem @*/ -{ - rpmtpm tpm; - - if (_rpmtpmPool == NULL) { - _rpmtpmPool = rpmioNewPool("tpm", sizeof(*tpm), -1, _rpmtpm_debug, - NULL, NULL, rpmtpmFini); - pool = _rpmtpmPool; - } - tpm = (rpmtpm) rpmioGetPool(pool, sizeof(*tpm)); - memset(((char *)tpm)+sizeof(tpm->_item), 0, sizeof(*tpm)-sizeof(tpm->_item)); - return tpm; -} +RPMIOPOOL_MODULE(tpm) rpmtpm rpmtpmNew(int ac, char ** av, struct poptOption *tbl, uint32_t flags) { @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmxar.c ============================================================================ $ cvs diff -u -r2.26.4.2 -r2.26.4.3 rpmxar.c --- rpm/rpmio/rpmxar.c 7 May 2016 14:55:29 -0000 2.26.4.2 +++ rpm/rpmio/rpmxar.c 27 Jun 2016 03:05:59 -0000 2.26.4.3 @@ -69,9 +69,6 @@ /*@unchecked@*/ int _xar_debug = 0; -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _xarPool; - /*@-globuse -mustmod@*/ static void rpmxarFini(void * _xar) /*@globals fileSystem @*/ @@ -93,25 +90,12 @@ } /*@=globuse =mustmod@*/ -static rpmxar rpmxarGetPool(/*@null@*/ rpmioPool pool) - /*@globals _xarPool, fileSystem @*/ - /*@modifies pool, _xarPool, fileSystem @*/ -{ - rpmxar xar; - - if (_xarPool == NULL) { - _xarPool = rpmioNewPool("xar", sizeof(*xar), -1, _xar_debug, - NULL, NULL, rpmxarFini); - pool = _xarPool; - } - xar = (rpmxar) rpmioGetPool(pool, sizeof(*xar)); - memset(((char *)xar)+sizeof(xar->_item), 0, sizeof(*xar)-sizeof(xar->_item)); - return xar; -} +#define _rpmxar_debug _xar_debug +RPMIOPOOL_MODULE(xar) rpmxar rpmxarNew(const char * fn, const char * fmode) { - rpmxar xar = rpmxarGetPool(_xarPool); + rpmxar xar = rpmxarGetPool(_rpmxarPool); int flags = ((fmode && *fmode == 'w') ? WRITE : READ); assert(fn != NULL); @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/set.c ============================================================================ $ cvs diff -u -r1.1.2.13 -r1.1.2.14 set.c --- rpm/rpmio/set.c 19 Apr 2016 13:01:19 -0000 1.1.2.13 +++ rpm/rpmio/set.c 27 Jun 2016 03:05:59 -0000 1.1.2.14 @@ -1335,24 +1335,7 @@ } } -/*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmsetPool = NULL; - -static rpmset rpmsetGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmsetPool, fileSystem @*/ - /*@modifies pool, _rpmsetPool, fileSystem @*/ -{ - rpmset set; - - if (_rpmsetPool == NULL) { - _rpmsetPool = rpmioNewPool("set", sizeof(*set), -1, _rpmset_debug, - NULL, NULL, rpmsetFini); - pool = _rpmsetPool; - } - set = (rpmset) rpmioGetPool(pool, sizeof(*set)); - memset(((char *)set)+sizeof(set->_item), 0, sizeof(*set)-sizeof(set->_item)); - return set; -} +RPMIOPOOL_MODULE(set) rpmset rpmsetNew(const char * fn, int flags) { @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org