rpm  5.4.14
Data Structures | Macros | Functions | Variables
rpmmalloc.c File Reference
#include "system.h"
#include <rpmiotypes.h>
#include <rpmio.h>
#include <rpmlog.h>
#include <yarn.h>
#include "debug.h"
Include dependency graph for rpmmalloc.c:

Go to the source code of this file.

Data Structures

struct  rpmioPool_s
 

Macros

#define EXIT_FAILURE   1
 

Functions

voidvmefail (size_t size)
 
rpmioPool rpmioFreePool (rpmioPool pool)
 Reclaim memory pool items. More...
 
rpmioPool rpmioNewPool (const char *name, size_t size, int limit, int flags, char *(*dbg)(void *item), void(*init)(void *item), void(*fini)(void *item))
 Create a memory pool. More...
 
rpmioItem rpmioUnlinkPoolItem (rpmioItem item, const char *msg, const char *fn, unsigned ln)
 Decrement a pool item refcount. More...
 
rpmioItem rpmioLinkPoolItem (rpmioItem item, const char *msg, const char *fn, unsigned ln)
 Increment a pool item refcount. More...
 
voidrpmioFreePoolItem (rpmioItem item, const char *msg, const char *fn, unsigned ln)
 Free a pool item. More...
 
rpmioItem rpmioGetPool (rpmioPool pool, size_t size)
 Get unused item from pool, or alloc a new item. More...
 
rpmioItem rpmioPutPool (rpmioItem item)
 Put unused item into pool (or free). More...
 
voidxmalloc (size_t size)
 
voidxcalloc (size_t nmemb, size_t size)
 
voidxrealloc (void *ptr, size_t size)
 
char * xstrdup (const char *str)
 

Variables

static rpmioPool _rpmioPool
 

Macro Definition Documentation

#define EXIT_FAILURE   1

Definition at line 24 of file rpmmalloc.c.

Referenced by vmefail().

Function Documentation

rpmioPool rpmioFreePool ( rpmioPool  pool)

Reclaim memory pool items.

Parameters
poolmemory pool (NULL uses global rpmio pool)
Returns
NULL always

Definition at line 72 of file rpmmalloc.c.

References _free(), _rpmioPool, assert(), count, D_, rpmioPool_s::have, rpmioPool_s::head, if(), rpmioPool_s::made, rpmioPool_s::name, NULL, rpmioItem_s::pool, rpmioPool_s::reused, rpmlog(), RPMLOG_DEBUG, RPMLOG_WARNING, rpmioPool_s::size, rpmioItem_s::use, VALGRIND_DESTROY_MEMPOOL, VALGRIND_HG_CLEAN_MEMORY, and void.

Referenced by main(), and rpmioClean().

void* rpmioFreePoolItem ( rpmioItem  item,
const char *  msg,
const char *  fn,
unsigned  ln 
)

Free a pool item.

Parameters
itempool item
msgdebugging msg (NULL disables debugging)
fnusually FILE
lnusually LINE
Returns
pool item (NULL on last dereference)

Definition at line 186 of file rpmmalloc.c.

References ANNOTATE_HAPPENS_AFTER, assert(), rpmioPool_s::dbg, rpmioPool_s::fini, rpmioPool_s::flags, fprintf(), L, rpmioPool_s::name, NULL, rpmioItem_s::pool, rpmioPutPool(), rpmioPool_s::size, rpmioItem_s::use, VALGRIND_HG_CLEAN_MEMORY, and VALGRIND_MEMPOOL_FREE.

Referenced by mireFreeAll(), rpmDigestFinal(), rpmDigestInit(), rpmmiInit(), and urlFini().

rpmioItem rpmioGetPool ( rpmioPool  pool,
size_t  size 
)
rpmioItem rpmioLinkPoolItem ( rpmioItem  item,
const char *  msg,
const char *  fn,
unsigned  ln 
)

Increment a pool item refcount.

Parameters
itempool item
msgdebugging msg (NULL disables debugging)
fnusually FILE
lnusually LINE
Returns
pool item

Definition at line 165 of file rpmmalloc.c.

References ANNOTATE_HAPPENS_BEFORE, rpmioPool_s::dbg, rpmioPool_s::flags, fprintf(), rpmioPool_s::name, NULL, rpmioItem_s::pool, and rpmioItem_s::use.

Referenced by newPackage(), newSpec(), rpmDigestDup(), rpmDigestInit(), rpmmiInit(), XfdNew(), XrpmtsiInit(), and XurlNew().

rpmioPool rpmioNewPool ( const char *  name,
size_t  size,
int  limit,
int  flags,
char *(*)(void *item)  dbg,
void(*)(void *item)  init,
void(*)(void *item)  fini 
)
rpmioItem rpmioPutPool ( rpmioItem  item)

Put unused item into pool (or free).

Parameters
_itemunused item
Returns
NULL always

Definition at line 264 of file rpmmalloc.c.

References _free(), rpmioPool_s::have, NULL, rpmioItem_s::pool, rpmioPool_s::tail, rpmioItem_s::use, and void.

Referenced by headerLoad(), rpmdbClose(), rpmdbNew(), and rpmioFreePoolItem().

rpmioItem rpmioUnlinkPoolItem ( rpmioItem  item,
const char *  msg,
const char *  fn,
unsigned  ln 
)

Decrement a pool item refcount.

Parameters
itempool item
msgdebugging msg (NULL disables debugging)
fnusually FILE
lnusually LINE
Returns
pool item (NULL on last dereference)

Definition at line 143 of file rpmmalloc.c.

References ANNOTATE_HAPPENS_AFTER, rpmioPool_s::dbg, rpmioPool_s::flags, fprintf(), rpmioPool_s::name, NULL, rpmioItem_s::pool, and rpmioItem_s::use.

void* vmefail ( size_t  size)

Definition at line 28 of file rpmmalloc.c.

References _, exit, EXIT_FAILURE, fprintf(), and NULL.

Referenced by xcalloc(), xmalloc(), xrealloc(), and xstrdup().

void* xcalloc ( size_t  nmemb,
size_t  size 
)
void* xmalloc ( size_t  size)

Definition at line 290 of file rpmmalloc.c.

References value, and vmefail().

void* xrealloc ( void ptr,
size_t  size 
)
Todo:
Annotate ptr with returned/out.

Definition at line 311 of file rpmmalloc.c.

References value, and vmefail().

char* xstrdup ( const char *  str)

Definition at line 321 of file rpmmalloc.c.

References vmefail().

Referenced by _poptSaveString(), _rpmtsCheck(), addFile(), addSource(), addTE(), addTriggerIndex(), argvAdd(), argvAppend(), argvSplit(), arHeaderRead(), armorFormat(), base64Format(), bncdataFormat(), cacheStashLatest(), cdataFormat(), cpio_doio(), createDir(), db3associate(), db3associate_foreign(), dbiFindMatches(), dbiTagsInit(), depflagsFormat(), deptypeFormat(), digestFormat(), doLookup(), doPatch(), doSetupMacro(), doUntar(), dupAttrRec(), fdSetOpen(), fflagsFormat(), for(), forceIncludeFile(), formatValue(), fpLookupSubdir(), fsmMakeLinks(), fsmStage(), ftpRealpath(), genSourceRpmName(), getFilesystemList(), getGidS(), getGname(), getGnameS(), getUidS(), getUname(), getUnameS(), glob(), headerCheck(), headerNEVRA(), headerReload(), headerSetBaseURL(), headerSetDigest(), headerSetOrigin(), headerSetParent(), headerSprintf(), hintFormat(), i18nTag(), iconvFormat(), if(), installArgCallback(), instprefixTag(), intFormat(), iosmMakeLinks(), iosmStage(), iosmStrerror(), isPart(), jsonFormat(), localeTag(), lookupPackage(), machAddEquiv(), main(), mireDup(), mireRegcomp(), parseChangelog(), parseCVOG(), parseExpressionBoolean(), parseExpressionString(), parseForSimple(), parseScript(), parseSimplePart(), parseSpec(), permsFormat(), pgpsigFormat(), pkgbaseurlTag(), pkgdigestTag(), pkgoriginTag(), pkgUnpackagedSubdirs(), populateInstallHeader(), processPackageFiles(), processSourceFiles(), pushMacro(), rdLead(), rdSignature(), rdToken(), readLineFromOFI(), realDateFormat(), Realpath(), rpmcliAllArgCallback(), rpmcliConfigured(), rpmcliImportPubkey(), rpmcliInstall(), rpmcliQuery(), rpmcliWalkFirst(), rpmdbExportHR_MIB(), rpmdbExportL10N_SQL(), rpmdbURIPath(), rpmdcParseCoreutils(), rpmdcParseZeroInstall(), rpmds_Single(), rpmdsCompare(), rpmdsCpuinfo(), rpmdsELF(), rpmdsEVRorder(), rpmdsLdconfig(), rpmdsNew(), rpmdsNVRMatchesDep(), rpmdsPipe(), rpmdsSysinfo(), rpmdsThis(), rpmEVRmire(), rpmEVRorder(), rpmEVRparse(), rpmExpand(), rpmfcGenerateDepends(), rpmfi_FClass_get(), rpmfiAddRelocation(), rpmfiDupeRelocations(), rpmfiNew(), rpmGetPath(), rpmgiInitFilter(), rpmgiNext(), rpmGlob(), rpmInitMacros(), rpmInstallSourcePackage(), rpmioAllArgCallback(), rpmioInit(), rpmioParse(), rpmkuFindPubkey(), rpmkuPassPhrase(), rpmlibMarkers(), rpmMCExpand(), rpmmgBuffer(), rpmmgFile(), rpmmgNew(), rpmmiInit(), rpmPermsString(), rpmpsAppend(), rpmpsmStage(), rpmpythonSlurp(), rpmQueryVerify(), rpmReadHeader(), rpmRebuildTargetVars(), rpmrepoCloseMDFile(), rpmrepoDoPkgMetadata(), rpmrepoDoRepoMetadata(), rpmrepoRealpath(), rpmSetMachine(), rpmsqlNew(), rpmsqlRun(), rpmsxMatch(), rpmtsFindPubkey(), rpmtsSetCurrDir(), rpmtsSetRootDir(), rpmWriteHeader(), rpnFormat(), runTriggersLoop(), shescapeFormat(), spewescapeFormat(), sql_open(), sql_step(), stashSt(), statFormat(), strdup_iconv_check(), strsubFormat(), triggercondsTag(), triggertypeFormat(), triggertypeTag(), unsatisfiedDepend(), urlFind(), urlSplit(), uuidFormat(), valueMakeString(), vrpmlog(), while(), writeFile(), writeLinkedFile(), writeRPM(), xmlFormat(), and yamlFormat().

Variable Documentation

rpmioPool _rpmioPool
static

Definition at line 70 of file rpmmalloc.c.

Referenced by rpmioFreePool().