rpm  5.4.4
Data Structures | Defines | Functions | Variables
rpmio/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

Defines

#define EXIT_FAILURE   1

Functions

void * vmefail (size_t size)
rpmioPool rpmioFreePool (rpmioPool pool)
 Reclaim memory pool items.
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.
rpmioItem rpmioUnlinkPoolItem (rpmioItem item, const char *msg, const char *fn, unsigned ln)
 Decrement a pool item refcount.
rpmioItem rpmioLinkPoolItem (rpmioItem item, const char *msg, const char *fn, unsigned ln)
 Increment a pool item refcount.
void * rpmioFreePoolItem (rpmioItem item, const char *msg, const char *fn, unsigned ln)
 Free a pool item.
rpmioItem rpmioGetPool (rpmioPool pool, size_t size)
 Get unused item from pool, or alloc a new item.
rpmioItem rpmioPutPool (rpmioItem item)
 Put unused item into pool (or free).
void * xmalloc (size_t size)
void * xcalloc (size_t nmemb, size_t size)
void * xrealloc (void *ptr, size_t size)
char * xstrdup (const char *str)

Variables

static rpmioPool _rpmioPool

Detailed Description

Definition in file rpmmalloc.c.


Define Documentation

#define EXIT_FAILURE   1

Definition at line 20 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 68 of file rpmmalloc.c.

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

Referenced by main(), rpmcliFini(), 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 182 of file rpmmalloc.c.

References ANNOTATE_HAPPENS_AFTER, rpmioPool_s::dbg, rpmioPool_s::fini, rpmioPool_s::flags, L, rpmioPool_s::name, 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 161 of file rpmmalloc.c.

References ANNOTATE_HAPPENS_BEFORE, rpmioPool_s::dbg, rpmioPool_s::flags, rpmioPool_s::name, 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 260 of file rpmmalloc.c.

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

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 139 of file rpmmalloc.c.

References ANNOTATE_HAPPENS_AFTER, rpmioPool_s::dbg, rpmioPool_s::flags, rpmioPool_s::name, rpmioItem_s::pool, and rpmioItem_s::use.

void* vmefail ( size_t  size)

Definition at line 24 of file rpmmalloc.c.

References _, and EXIT_FAILURE.

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

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

Definition at line 286 of file rpmmalloc.c.

References vmefail().

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

Definition at line 307 of file rpmmalloc.c.

References vmefail().

char* xstrdup ( const char *  str)

Definition at line 317 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(), expandMacro(), fdSetOpen(), fflagsFormat(), forceIncludeFile(), formatValue(), fpLookupSubdir(), fsmMakeLinks(), fsmStage(), ftpRealpath(), genSourceRpmName(), getFilesystemList(), getGidS(), getGname(), getGnameS(), getUidS(), getUname(), getUnameS(), glob(), grepArgCallback(), headerCheck(), headerNEVRA(), headerReload(), headerSetBaseURL(), headerSetDigest(), headerSetOrigin(), headerSetParent(), headerSprintf(), i18nTag(), iconvFormat(), installArgCallback(), instprefixTag(), intFormat(), iosmMakeLinks(), iosmStage(), iosmStrerror(), isPart(), jsonFormat(), localeTag(), lookupPackage(), machAddEquiv(), main(), mireDup(), mireRegcomp(), mireSetLocale(), mtreeReadExcludes(), parseChangelog(), parseCVOG(), parseExpressionBoolean(), parseExpressionString(), parseForSimple(), parseRCPOT(), parseScript(), parseSimplePart(), parseSpec(), permsFormat(), pgpsigFormat(), pkgbaseurlTag(), pkgdigestTag(), pkgoriginTag(), pkgUnpackagedSubdirs(), populateInstallHeader(), printNewSpecfile(), processPackageFiles(), processSourceFiles(), pushMacro(), rdLead(), rdSignature(), rdToken(), readLineFromOFI(), realDateFormat(), Realpath(), rpmcliAllArgCallback(), rpmcliConfigured(), rpmcliImportPubkey(), rpmcliInit(), rpmcliInstall(), rpmcliQuery(), rpmcliWalkFirst(), rpmdbExportInfo(), rpmdbURIPath(), rpmdcParseCoreutils(), rpmdcParseZeroInstall(), rpmds_compare(), rpmds_iternext(), rpmds_Single(), rpmdsCpuinfo(), rpmdsELF(), rpmdsGetconf(), rpmdsLdconfig(), rpmdsNew(), rpmdsSysinfo(), rpmdsThis(), rpmEVRmire(), rpmEVRorder(), rpmEVRparse(), rpmExpand(), rpmfcGenerateDepends(), rpmfd_Fopen(), rpmfi_BN(), rpmfi_Digest(), rpmfi_DN(), rpmfi_FClass(), rpmfi_FClass_get(), rpmfi_FGroup(), rpmfi_FLink(), rpmfi_FN(), rpmfi_FUser(), rpmfi_subscript(), rpmfiAddRelocation(), rpmfiDupeRelocations(), rpmfiNew(), rpmGetPath(), rpmgiInitFilter(), rpmgiNext(), rpmGlob(), rpmInitMacros(), rpmInstallSourcePackage(), rpmioAllArgCallback(), rpmioInit(), rpmioParse(), rpmkuFindPubkey(), rpmkuPassPhrase(), rpmlibMarkers(), rpmMCExpand(), rpmmgBuffer(), rpmmgFile(), rpmmgNew(), rpmmiInit(), rpmPermsString(), rpmps_ass_sub(), rpmpsAppend(), rpmpsmStage(), rpmpythonSlurp(), rpmQueryVerify(), rpmReadHeader(), rpmRebuildTargetVars(), rpmrepoCloseMDFile(), rpmrepoDoPkgMetadata(), rpmrepoDoRepoMetadata(), rpmrepoRealpath(), rpmSetMachine(), rpmsqlNew(), rpmsqlRun(), rpmsxMatch(), rpmts_Check(), 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(), vrpmlog(), writeFile(), writeLinkedFile(), writeRPM(), xmlFormat(), and yamlFormat().


Variable Documentation

Definition at line 66 of file rpmmalloc.c.

Referenced by rpmioFreePool().