xalloc.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define safe_free(x)   while ((x)) { free_const((x)); (x) = nullptr; }
 

Functions

void * xcalloc (size_t n, size_t sz)
 
void * xmalloc (size_t sz)
 
void * xrealloc (void *s, size_t sz)
 
void free_const (const void *s)
 
static void xfree (const void *p)
 

Macro Definition Documentation

◆ safe_free

#define safe_free (   x)    while ((x)) { free_const((x)); (x) = nullptr; }

safe_free() - same as free(3). Used for portability. Accepts pointers to dynamically allocated const data. Will not call free(3) if the pointer is nullptr. Sets the pointer to nullptr on completion.

Use xfree() if the pointer does not need to be set afterward.

Define failure_notify to receive error message. otherwise perror() is used to display it.

Definition at line 73 of file xalloc.h.

Function Documentation

◆ free_const()

void free_const ( const void *  s)

free_const() - Same as free(3). Used for portability. Accepts pointers to dynamically allocated const data.

Define failure_notify to receive error message. otherwise perror() is used to display it.

Definition at line 153 of file xalloc.cc.

Referenced by xfree().

◆ xcalloc()

void * xcalloc ( size_t  n,
size_t  sz 
)

xcalloc() - same as calloc(3). Used for portability. Never returns nullptr; fatal on error.

Define failure_notify to receive error message. otherwise perror() is used to display it.

Definition at line 71 of file xalloc.cc.

References failure_notify.

Referenced by FileMap::FileMap(), MemChunk::MemChunk(), StatHist::StatHist(), accessLogReader(), MemPoolMalloc::allocate(), asnAddNet(), authDigestNonceEncode(), buildUrlFromHost(), cacheCreate(), cacheEntryCreate(), Comm::CallbackTableInit(), Ident::ClientAdd(), clientBeginRequest(), configDoConfigure(), icp_common_t::CreateMessage(), createRemovalPolicy_heap(), createRemovalPolicy_lru(), StatHist::deltaPctile(), do_open(), errorInitialize(), fileIteratorCreate(), ftpListParseParts(), getsymbol(), FileMap::grow(), Fs::Ufs::UFSSwapDir::HandleCleanEvent(), hash_create(), hashFreeItems(), heap_walkInit(), html_quote(), idnsAddPathComponent(), fde::Init(), SharedMemory::init(), CacheDigest::init(), StatHist::init(), ipc_thread_1(), ipc_thread_2(), LoadSecurityDll(), logfile_mod_daemon_open(), logfile_mod_stdio_open(), logfile_mod_udp_open(), logfileNewBuffer(), Debug::LogMessage(), lru_purgeInit(), lru_walkInit(), main(), memAllocBuf(), memAllocString(), netdbDump(), netdbPeerAdd(), netdbPurgeLRU(), netdbReloadState(), new_heap(), StatHist::operator=(), parse_hostdomaintype(), parse_IpAddress_list(), ConnStateData::parseHttpRequest(), prepareAcceleratedURL(), ConnStateData::prepareTlsSwitchingURL(), prepareTransparentURL(), PutEnvironment(), Format::QuoteMimeBlob(), read_passwd_file(), read_request(), rfc1035MessageUnpack(), rfc1738_do_escape(), Comm::SelectLoopInit(), snmpHandleUdp(), squidaio_shutdown(), storeRebuildStart(), swapStateReader(), urnParseReply(), wccp2_add_service_list(), wccp2AssignBuckets(), wccp2HandleUdp(), wccp2Init(), and Fs::Ufs::UFSSwapDir::writeCleanStart().

◆ xfree()

static void xfree ( const void *  p)
inlinestatic

xfree() - same as free(3). Used for portability. Accepts pointers to dynamically allocated const data. Will not call free(3) if the pointer is nullptr.

Pointer is left with a value on completion. Use safe_free() if the pointer needs to be set to nullptr afterward.

Define failure_notify to receive error message. otherwise perror() is used to display it.

Definition at line 60 of file xalloc.h.

References free_const().

◆ xmalloc()

void * xmalloc ( size_t  sz)

xmalloc() - same as malloc(3). Used for portability. Never returns nullptr; fatal on error.

Define failure_notify to receive error message. otherwise perror() is used to display it.

Definition at line 100 of file xalloc.cc.

References failure_notify.

◆ xrealloc()

void * xrealloc ( void *  s,
size_t  sz 
)

xrealloc() - same as realloc(3). Used for portability. Never returns nullptr; fatal on error.

Definition at line 126 of file xalloc.cc.

References failure_notify.

Referenced by _heap_grow(), add_User_Group(), cbdataInternalAddType(), memReallocBuf(), parseOneConfigFile(), snmpAddNodeChild(), snmpCreateOidFromStr(), storeReplAdd(), and WIN32_build_argv().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors