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) = NULL; }
 

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) = NULL; }

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 NULL. Sets the pointer to NULL 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.

References s.

Referenced by xfree().

◆ xcalloc()

void* xcalloc ( size_t  n,
size_t  sz 
)

xcalloc() - same as calloc(3). Used for portability. Never returns NULL; 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, NULL, and sz.

Referenced by FileMap::FileMap(), MemChunk::MemChunk(), StatHist::StatHist(), _db_print(), accessLogReader(), MemPoolMalloc::allocate(), asnAddNet(), authDigestNonceEncode(), buildUrlFromHost(), cacheCreate(), cacheEntryCreate(), Comm::CallbackTableInit(), carpInit(), 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(), lru_purgeInit(), main(), memAllocBuf(), memAllocString(), netdbDump(), netdbPeerAdd(), netdbPurgeLRU(), netdbReloadState(), new_heap(), StatHist::operator=(), parse_hostdomaintype(), parse_IpAddress_list(), parse_sslproxy_cert_adapt(), parse_sslproxy_cert_sign(), ConnStateData::parseHttpRequest(), peerSourceHashInit(), peerUserHashInit(), prepareAcceleratedURL(), ConnStateData::prepareTlsSwitchingURL(), prepareTransparentURL(), PutEnvironment(), Format::QuoteMimeBlob(), read_passwd_file(), read_request(), Mem::Report(), 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 NULL.

Pointer is left with a value on completion. Use safe_free() if the pointer needs to be set to NULL 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 NULL; 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, NULL, and sz.

◆ xrealloc()

void* xrealloc ( void *  s,
size_t  sz 
)

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

Definition at line 126 of file xalloc.cc.

References failure_notify, NULL, s, and sz.

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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors