suricata
util-mem.h File Reference
#include "util-atomic.h"
Include dependency graph for util-mem.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SCMalloc(a)
 
#define SCRealloc(x, a)
 
#define SCCalloc(nm, a)
 
#define SCStrdup(a)
 
#define SCStrndup(a, b)
 
#define SCFree(a)
 
#define SCMallocAligned(a, b)
 wrapper for allocing aligned mem More...
 
#define SCFreeAligned(a)
 Free aligned memory. More...
 

Functions

 SC_ATOMIC_EXTERN (unsigned int, engine_stage)
 

Detailed Description

Author
Pablo Rincon Crespo pablo.nosp@m..rin.nosp@m.con.c.nosp@m.resp.nosp@m.o@gma.nosp@m.il.c.nosp@m.om
Bill Meeks billm.nosp@m.eeks.nosp@m.8@gma.nosp@m.il.c.nosp@m.om

Utility Macros for memory management

Todo:
Add wrappers for functions that allocate/free memory here. Currently we have malloc, calloc, realloc, strdup, strndup and free, but there are more.

Definition in file util-mem.h.

Macro Definition Documentation

#define SCCalloc (   nm,
 
)
Value:
({ \
void *ptrmem = NULL; \
\
ptrmem = calloc((nm), (a)); \
if (ptrmem == NULL) { \
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
SCLogError(SC_ERR_MEM_ALLOC, "SCCalloc failed: %s, while trying " \
"to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)(a)); \
SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \
exit(EXIT_FAILURE); \
} \
} \
(void*)ptrmem; \
})
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:294
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
Definition: util-atomic.h:192

Definition at line 253 of file util-mem.h.

Referenced by AFPSetBPFFilter(), AlertFastLogInitCtx(), AppLayerExpectationCreate(), AppLayerParserStreamTruncated(), BytesToString(), ConfNodeNew(), DCERPCInit(), DecodeMPLS(), DefragInitConfig(), DefragTrackerFreeFrags(), DetectAddressMapFree(), DetectAppLayerInspectEngineRegister2(), DetectAppLayerMpmRegister2(), DetectAppLayerMpmRegisterByParentId(), DetectBase64DecodeDoMatch(), DetectBufferTypeGetByIdTransforms(), DetectBufferTypeMaxId(), DetectContentDataParse(), DetectDceOpnumRegister(), DetectEngineAppInspectionEngine2Signature(), DetectEngineMultiTenantSetup(), DetectEnginePktInspectionRun(), DetectEngineResetMaxSigId(), DetectFilemagicRegister(), DetectLoaderQueueTask(), DetectLoadersInit(), DetectMpmInitializeAppMpms(), DetectMpmInitializePktMpms(), DetectNfsProcedureRegister(), DetectNfsVersionRegister(), DetectParseRegexAddToFreeList(), DetectPcrePayloadMatch(), DetectPktInspectEngineRegister(), DetectPktMpmRegister(), DetectPktMpmRegisterByParentId(), DetectPktvarRegister(), DetectRegisterThreadCtxGlobalFuncs(), DetectSNMPPduTypeRegister(), DetectSNMPVersionRegister(), DetectSslVersionRegister(), DetectTlsCertsRegister(), DetectTlsValidityRegister(), DetectTlsVersionRegister(), DetectVarStoreMatch(), DetectVarStoreMatchKeyValue(), DNP3FreeObjectPointList(), DNP3PointListAlloc(), FlowVarAddIdValue(), FlowVarAddKeyValue(), FTPMemcapGlobalCounter(), HTPCalloc(), HttpHeaderThreadDataInit(), InspectionBufferApplyTransforms(), InspectionBufferInit(), Ja3BufferInit(), JsonBuildFileInfoRecord(), JsonDNSLogAnswer(), LiveDevUseBypass(), LiveRegisterDevice(), LiveRegisterDeviceName(), LogCustomFormatAlloc(), LogCustomFormatNodeAlloc(), LogHttpLogInitCtx(), LogStatsLogThreadDeinit(), LogTcpDataLogInitCtx(), MimeDecAddEntity(), MpmStorePrepareBuffer(), NapatechPacketLoopZC(), NapatechStreamThreadInit(), NoWinDivertSupportExit(), OutputJsonRegister(), OutputLoggerThreadInit(), OutputRegisterFiledataModule(), OutputRegisterFiledataSubModule(), OutputRegisterFileModule(), OutputRegisterFileRotationFlag(), OutputRegisterFileSubModule(), OutputRegisterFlowModule(), OutputRegisterFlowSubModule(), OutputRegisterPacketModule(), OutputRegisterPacketSubModule(), OutputRegisterRootLogger(), OutputRegisterStatsModule(), OutputRegisterStatsSubModule(), OutputRegisterStreamingModule(), OutputRegisterStreamingSubModule(), PacketBypassCallback(), PacketCallocExtPkt(), PcapDetermineDirectoryOrFile(), PktVarAdd(), PktVarAddKeyValue(), PoolInit(), PoolThreadInit(), PrefilterGenericMpmPktRegister(), PrefilterGenericMpmRegister(), PrefilterInit(), PrefilterMpmFiledataRegister(), printUUID(), ReceivePcapThreadInit(), RegisterSSHParsers(), RuleMatchCandidateTxArrayInit(), RunModeIdsAFPRegister(), RunModeNapatechRegister(), RunModeShutDown(), SCACTilePreparePatterns(), SCProfilePacketStart(), SCProfilingKeywordInitCounters(), SCProfilingKeywordThreadSetup(), SCProfilingSghInitCounters(), SCProfilingSghThreadSetup(), SCProfilingSghUpdateCounter(), SigAlloc(), SigMatchList2DataArray(), SigStringAlloc(), SMTPStateAlloc(), SSLVersionToString(), StatsSetUI64(), StreamTcpReassembleGetMemcap(), TAILQ_HEAD(), ThresholdIPPairTimeoutCheck(), TLSGetIPInformations(), TmThreadsRegisterThread(), Unified2AlertInitCtx(), UTHAddSessionToFlow(), and VarNameStoreSetupStaging().

#define SCFree (   a)
Value:
({ \
free(a); \
})

Definition at line 322 of file util-mem.h.

Referenced by __attribute__(), AFPGetLinkType(), AFPIsFanoutSupported(), AFPSetBPFFilter(), AlertFastLogInitCtx(), AlertFastLogThreadDeinit(), AlertFastLogThreadInit(), AppLayerDecoderEventsFreeEvents(), AppLayerDestroyCtxThread(), AppLayerExpectationCreate(), AppLayerExpectationGetDataId(), AppLayerParserStateFree(), AppLayerParserThreadCtxFree(), AppLayerProtoDetectDeSetup(), AppLayerProtoDetectDestroyCtxThread(), BloomFilterCountingFree(), BloomFilterCountingInit(), BloomFilterFree(), BloomFilterInit(), BoyerMooreCtxDeInit(), CleanupPcapFileDirectoryVars(), CleanupPcapFileFileVars(), CleanupPendingFile(), CleanVariableResolveList(), ConfNodeDump(), ConfNodeFree(), ConfNodePrune(), ConfSet(), ConfSetFinal(), ConfSetFromString(), ConfYamlLoadFileWithPrefix(), DCERPCCleanup(), DCERPCUuidListFree(), DecodeEthernet(), DecodeGRE(), DecodeICMPV6(), DecodeIPV4(), DecodeIPV6(), DecodeMPLS(), DecodePPP(), DecodePPPOESession(), DecodeRaw(), DecodeTCP(), DecodeThreadVarsFree(), DefragHashShutdown(), DefragTrackerFreeFrags(), DefragTrackerMoveToSpare(), DerFree(), DetectAckRegister(), DetectAddressFree(), DetectAddressHeadFree(), DetectAddressMapFree(), DetectAddressParseString(), DetectAppLayerEventRegister(), DetectAsn1Register(), DetectBase64DecodeDoMatch(), DetectBufferTypeMaxId(), DetectBypassRegister(), DetectByteExtractDoMatch(), DetectBytejumpDoMatch(), DetectBytetestDoMatch(), DetectCipServiceRegister(), DetectContentFree(), DetectContentParse(), DetectContentPrint(), DetectCsumRegister(), DetectDceIfaceRegister(), DetectDceOpnumRegister(), DetectDetectionFilterRegister(), DetectDsizeRegister(), DetectEngineAppInspectionEngineSignatureFree(), DetectEngineCtxFree(), DetectEngineCtxInitWithPrefix(), DetectEngineEventRegister(), DetectEngineIPOnlyThreadDeinit(), DetectEngineMultiTenantSetup(), DetectEngineResetMaxSigId(), DetectEngineStateFree(), DetectEngineThreadCtxInit(), DetectEnipCommandRegister(), DetectFileextRegister(), DetectFilemagicRegister(), DetectFilenameRegister(), DetectFilesizeRegister(), DetectFilestoreRegister(), DetectFlagsRegister(), DetectFlagsSignatureNeedsSynOnlyPackets(), DetectFlowbitFree(), DetectFlowbitMatch(), DetectFlowbitsAnalyze(), DetectFlowFree(), DetectFlowintFree(), DetectFlowintMatch(), DetectFlowvarMatch(), DetectFlowvarPostMatchSetup(), DetectFlowvarRegister(), DetectFragBitsRegister(), DetectFragOffsetFree(), DetectFragOffsetRegister(), DetectFtpbounceRegister(), DetectFtpdataRegister(), DetectGeoipRegister(), DetectHostbitFree(), DetectIcmpIdFree(), DetectIcmpIdRegister(), DetectIcmpSeqFree(), DetectIcmpSeqRegister(), DetectICodeFree(), DetectIdFree(), DetectIpOptsFree(), DetectIPProtoRegister(), DetectIPProtoRemoveAllSMs(), DetectIPRepFree(), DetectIPRepRegister(), DetectIsdataatFree(), DetectIsdataatRegister(), DetectIsdataatSetup(), DetectITypeFree(), DetectL3ProtoRegister(), DetectLuaRegister(), DetectMarkDataFree(), DetectMarkRegister(), DetectMetadataFree(), DetectMetadataHashFree(), DetectNfsProcedureRegister(), DetectNfsVersionRegister(), DetectParseDupSigHashFree(), DetectParseFreeRegexes(), DetectPcrePayloadMatch(), DetectPktvarRegister(), DetectPortFree(), DetectPortListsAreEqual(), DetectReferenceFree(), DetectReplaceExecuteInternal(), DetectReplaceFreeInternal(), DetectReplaceRegister(), DetectRpcFree(), DetectRpcRegister(), DetectSameipRegister(), DetectSeqRegister(), DetectSetFastPatternAndItsId(), DetectSetupParseRegexes(), DetectSNMPPduTypeRegister(), DetectSNMPVersionRegister(), DetectSshSoftwareVersionRegister(), DetectSshVersionRegister(), DetectSslStateRegister(), DetectSslVersionRegister(), DetectStreamSizeFree(), DetectStreamSizeRegister(), DetectTagDataFree(), DetectTagRegister(), DetectTcpmssFree(), DetectTcpmssRegister(), DetectTemplate2Free(), DetectTemplate2Register(), DetectTemplateRegister(), DetectThresholdRegister(), DetectTlsCertsRegister(), DetectTlsRegister(), DetectTlsValidityRegister(), DetectTlsVersionRegister(), DetectTosRegister(), DetectTtlFree(), DetectUricontentRegister(), DetectUrilenFree(), DetectUrilenRegister(), DetectUrilenValidateContent(), DetectVarProcessListInternal(), DetectVarStoreMatch(), DetectWindowFree(), DetectWindowRegister(), DetectXbitFree(), DetectXbitMatchHost(), DetectXbitsRegister(), DNP3FreeObjectPoint(), DNP3FreeObjectPointList(), EngineAnalysisFP(), EngineDone(), FileContainerFree(), FlowBitFree(), FlowFree(), FlowStorageRegister(), FlowVarFree(), FTPMemcapGlobalCounter(), GetFlowBypassInfoID(), GlobalsInitPreConfig(), HashListTableFree(), HashListTableInit(), HashListTableRemove(), HashTableAdd(), HashTableFree(), HashTableInit(), HashTableRemove(), HostClearMemory(), HostFree(), HostFreeStorage(), HtpConfigRestoreBackup(), HTPFree(), HTPFreeConfig(), HttpHeaderThreadDataFree(), ICMPv4GetCounterpart(), InspectionBufferApplyTransforms(), InspectionBufferFree(), IPOnlyCIDRListFree(), IPOnlyDeinit(), IPOnlyPrepare(), IPPairFree(), IPPairStorageRegister(), Ja3BufferAppendBuffer(), Ja3BufferFree(), JsonBuildFileInfoRecord(), JsonDNSLogAnswer(), LiveDeviceFinalize(), LiveDeviceListClean(), LiveRegisterDevice(), LiveRegisterDeviceName(), LogCustomFormatFree(), LogCustomFormatNodeFree(), LogFileFreeCtx(), LogHttpLogInitCtx(), LogHttpLogThreadDeinit(), LogHttpLogThreadInit(), LogStatsLogThreadDeinit(), LogStatsLogThreadInit(), LogTcpDataLogInitCtx(), LogTcpDataLogThreadDeinit(), LogTcpDataLogThreadInit(), MemBufferFree(), MimeDecAddEntity(), MimeDecDeInitParser(), MimeDecFreeEntity(), MimeDecFreeField(), MimeDecFreeUrl(), MimeDecInitParser(), MimeDecParseFullMsg(), MpmACBSRegister(), MpmFactoryDeRegisterAllMpmCtxProfiles(), MpmFactoryReClaimMpmCtx(), MpmFactoryRegisterMpmCtxProfile(), MpmFreePattern(), MpmStorePrepareBuffer(), NapatechPacketLoopZC(), NFQContextsClean(), NoNFLOGSupportExit(), NoWinDivertSupportExit(), OutputDeregisterAll(), OutputFiledataShutdown(), OutputFileShutdown(), OutputFlowLogThreadDeinit(), OutputFlowShutdown(), OutputJsonRegister(), OutputLoggerThreadDeinit(), OutputPacketShutdown(), OutputRegisterFiledataLogger(), OutputRegisterFileLogger(), OutputRegisterPacketLogger(), OutputRegisterTxLogger(), OutputStatsLog(), OutputStatsShutdown(), OutputStreamingShutdown(), OutputTxShutdown(), OutputUnregisterFileRotationFlag(), PacketFree(), PacketProfileLoggertIdToString(), PerCentEncodingMatch(), PktVarFree(), PmqCleanup(), PoolFree(), PoolGet(), PoolInit(), PoolReturn(), PoolThreadExpand(), PoolThreadFree(), PrefilterGenericMpmPktRegister(), PrefilterGenericMpmRegister(), PrefilterInit(), PrefilterSetupRuleGroup(), printUUID(), ReceiveAFPThreadDeinit(), ReceiveAFPThreadInit(), ReceiveErfDagThreadInit(), ReceiveNFQThreadDeinit(), ReceivePcapThreadInit(), ReceivePfringThreadDeinit(), ReceivePfringThreadInit(), RegisterAllModules(), RegisterDNP3Parsers(), RegisterModbusParsers(), RetrieveFPForSig(), ROHashFree(), ROHashInitFinalize(), RuleMatchCandidateTxArrayFree(), RunModeDispatch(), RunModeErfFileAutoFp(), RunModeFilePcapAutoFp(), RunModeIdsAFPRegister(), RunModeIdsNetmapRegister(), RunModeIdsNflogRegister(), RunModeIdsPcapRegister(), RunModeIdsPfringRegister(), RunModeRegisterNewRunMode(), RunModeSetIPSAutoFp(), RunModeSetLiveCaptureAutoFp(), RunModeUnixSocketGetDefaultMode(), SCACBSDestroyCtx(), SCACBSDestroyThreadCtx(), SCACBSPreparePatterns(), SCACDestroyCtx(), SCACDestroyThreadCtx(), SCACPreparePatterns(), SCACTileDestroyCtx(), SCACTileDestroyThreadCtx(), SCACTilePreparePatterns(), SCAsn1CtxDestroy(), SCAsn1CtxNew(), SCClassConfDeAllocClasstype(), SCClassConfDeInitContext(), SCHInfoAddHostOSInfo(), SCHInfoGetHostOSFlavour(), SCLogAllocLogInitData(), SCLogAllocLogOPBuffer(), SCLogDeInitLogModule(), SCLogLoadConfig(), SCLogReleaseFDFilter(), SCLogReleaseFGFilters(), SCProfilingDestroy(), SCProfilingInit(), SCProfilingKeywordDestroyCtx(), SCProfilingKeywordThreadCleanup(), SCProfilingKeywordUpdateCounter(), SCProfilingPrefilterThreadCleanup(), SCProfilingPrefilterUpdateCounter(), SCProfilingRuleDestroyCtx(), SCProfilingRulesGlobalInit(), SCProfilingRuleThreadCleanup(), SCProfilingSghThreadCleanup(), SCProfilingSghUpdateCounter(), SCProtoNameDeInit(), SCProtoNameInit(), SCRadixAddKeyIPV6String(), SCRadixPrintTree(), SCRadixReleaseRadixTree(), SCRConfAllocSCRConfReference(), SCRConfDeAllocSCRConfReference(), SCSigOrderSignatures(), SCSigSignatureOrderingModuleCleanup(), SCThresholdConfInitContext(), SigAddressCleanupStage1(), SigAddressPrepareStage4(), SigAlloc(), SigFree(), SigGetThresholdTypeIter(), SigGroupHeadFree(), SigGroupHeadInitDataFree(), SigGroupHeadStore(), SigInit(), SigLoadSignatures(), SigMatchFree(), SigParseApplyDsizeToContent(), SigStringAlloc(), SigStringAppend(), SMTPProcessDataChunk(), SMTPStateAlloc(), SRepDestroy(), SRepHostTimedOut(), SRepInit(), SRepResetVersion(), SSLVersionToString(), StatsReleaseCounters(), StatsSetUI64(), StorageAllocById(), StorageCleanup(), StorageFinalize(), StorageFree(), StreamingBufferCompareRawData(), StreamTcpReassembleFreeThreadCtx(), StreamTcpReassembleGetMemcap(), StreamTcpSessionCleanup(), StreamTcpThreadDeinit(), StringHashFreeFunc(), TagHashAddTag(), TagTimeoutCheck(), TcpSackCompare(), ThresholdContextDestroy(), ThresholdListFree(), TLSGetIPInformations(), TmModuleDecodeAFPRegister(), TmModuleDecodeNetmapRegister(), TmqhInputFlow(), TmqhOutputFlowFreeCtx(), TmqhOutputFlowSetupCtx(), TmqResetQueues(), TmThreadCreate(), TmThreadInitMC(), TmThreadKillThreads(), TmThreadsUnregisterThread(), Unified2AlertInitCtx(), Unified2AlertThreadDeinit(), Unified2AlertThreadInit(), UtCleanup(), UTHBuildFlow(), UTHBuildPacketArrayFromEth(), UTHBuildPacketIPV6Real(), UTHBuildPacketReal(), UTHFreePacket(), UTHRemoveSessionFromFlow(), ValidateIPV4Address(), ValidateIPV6Address(), and XBitFree().

#define SCFreeAligned (   a)
Value:
({ \
free(a); \
})

Free aligned memory.

Not needed for mem alloc'd by posix_memalign, but for possible future use of _mm_malloc needing _mm_free.

Definition at line 388 of file util-mem.h.

Referenced by FlowShutdown(), HostShutdown(), IPPairShutdown(), PrefilterAppendTxEngine(), and PrefilterFreeEnginesList().

#define SCMalloc (   a)
Value:
({ \
void *ptrmem = NULL; \
\
ptrmem = malloc((a)); \
if (ptrmem == NULL) { \
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
uintmax_t scmalloc_size_ = (uintmax_t)(a); \
SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying " \
"to allocate %"PRIuMAX" bytes", strerror(errno), scmalloc_size_); \
SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \
exit(EXIT_FAILURE); \
} \
} \
(void*)ptrmem; \
})
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:294
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
Definition: util-atomic.h:192

Definition at line 222 of file util-mem.h.

Referenced by AddVariableToResolveList(), AFPGetLinkType(), AFPPeersListCheck(), AlertFastLogThreadInit(), AppLayerDecoderEventsSetEventRaw(), AppLayerGetCtxThread(), AppLayerParserStateAlloc(), AppLayerParserThreadCtxAlloc(), AppLayerProtoDetectGetCtxThread(), BloomFilterCountingInit(), BloomFilterInit(), BoyerMooreCtxInit(), ConfLoadCompleteIncludePath(), DecodeCIPRequestPathPDU(), DecodeEthernet(), DecodeICMPV6(), DecodeMPLS(), DecodeThreadVarsAlloc(), DefragRbFragCompare(), DefragTrackerMoveToSpare(), DefragTrackerQueueNew(), DetectAckRegister(), DetectAddressHeadInit(), DetectAddressInit(), DetectAddressParseString(), DetectAppLayerEventRegister(), DetectAppLayerInspectEngineRegister(), DetectAppLayerInspectEngineRegister2(), DetectAsn1Register(), DetectBypassRegister(), DetectByteExtractDoMatch(), DetectBytejumpDoMatch(), DetectBytetestDoMatch(), DetectCipServiceRegister(), DetectContentParse(), DetectContentPrint(), DetectCsumRegister(), DetectDceIfaceRegister(), DetectDceOpnumRegister(), DetectDetectionFilterRegister(), DetectDsizeRegister(), DetectEngineEventRegister(), DetectEngineInspectPktBufferGeneric(), DetectEngineIPOnlyThreadInit(), DetectEngineResetMaxSigId(), DetectEngineStateAlloc(), DetectEngineThreadCtxInit(), DetectEnipCommandRegister(), DetectFileextRegister(), DetectFilemagicRegister(), DetectFilenameRegister(), DetectFilesizeRegister(), DetectFilestoreRegister(), DetectFlagsRegister(), DetectFlagsSignatureNeedsSynOnlyPackets(), DetectFlowbitMatch(), DetectFlowbitsAnalyze(), DetectFlowintMatch(), DetectFlowMatch(), DetectFlowvarMatch(), DetectFlowvarPostMatchSetup(), DetectFragBitsRegister(), DetectFragOffsetFree(), DetectFragOffsetRegister(), DetectFtpbounceRegister(), DetectFtpdataRegister(), DetectGeoipRegister(), DetectHostbitFree(), DetectIcmpIdRegister(), DetectIcmpSeqRegister(), DetectIdRegister(), DetectIpOptsFree(), DetectIPProtoRegister(), DetectIPProtoRemoveAllSMs(), DetectIPRepRegister(), DetectIsdataatRegister(), DetectLoadCompleteSigPath(), DetectLuaRegister(), DetectMarkRegister(), DetectMetadataHashFree(), DetectParseDupSigHashFree(), DetectPcrePayloadMatch(), DetectPortListsAreEqual(), DetectReferenceFree(), DetectRegisterThreadCtxFuncs(), DetectReplaceAddToList(), DetectReplaceRegister(), DetectRpcRegister(), DetectSeqRegister(), DetectSetFastPatternAndItsId(), DetectSetupParseRegexes(), DetectSignatureSetAppProto(), DetectSshSoftwareVersionRegister(), DetectSshVersionRegister(), DetectSslStateRegister(), DetectStreamSizeRegister(), DetectTagRegister(), DetectTcpmssRegister(), DetectTemplate2Register(), DetectTemplateRegister(), DetectThresholdRegister(), DetectTlsRegister(), DetectTlsValidityRegister(), DetectTosRegister(), DetectTtlRegister(), DetectUricontentRegister(), DetectUrilenRegister(), DetectWindowRegister(), DetectXbitFree(), DetectXbitMatchHost(), DetectXbitsRegister(), EngineAnalysisFP(), EngineDone(), FileContainerAlloc(), FileContainerFree(), FlowAlloc(), FlowQueueNew(), FlowStorageRegister(), FlowVarAddIntNoLock(), FTPMemcapGlobalCounter(), HashListTableAdd(), HashListTableInit(), HashTableAdd(), HashTableInit(), HostAlloc(), HostBitsTimedoutCheck(), HostFreeStorage(), HostQueueNew(), HtpConfigRestoreBackup(), HTPConfigure(), HTPMalloc(), ICMPv4GetCounterpart(), IPOnlyCIDRListFree(), IPOnlyInit(), IPPairAlloc(), IPPairBitsTimedoutCheck(), IPPairQueueNew(), IPPairStorageRegister(), Ja3BufferAddValue(), Ja3GenerateHash(), JsonBuildFileInfoRecord(), JsonDNSLogAnswer(), LogFileNewCtx(), LogHttpLogInitCtx(), LogHttpLogThreadInit(), LogStatsLogThreadDeinit(), LogStatsLogThreadInit(), LogTcpDataLogInitCtx(), LogTcpDataLogThreadInit(), MemBufferCreateNew(), MimeDecAddEntity(), MimeDecAddField(), MimeDecFindField(), MimeDecInitParser(), MimeDecParseFullMsg(), MpmACBSRegister(), MpmAddPattern(), MpmAddPatternCI(), MpmFactoryGetMpmCtxForProfile(), MpmFactoryRegisterMpmCtxProfile(), NoNFLOGSupportExit(), OutputFlowLogThreadInit(), OutputRegisterFiledataLogger(), OutputRegisterFileLogger(), OutputRegisterFlowLogger(), OutputRegisterPacketLogger(), OutputRegisterStatsLogger(), OutputRegisterStreamingLogger(), OutputRegisterTxLogger(), OutputStatsLog(), PacketCopyDataOffset(), PacketGetFromAlloc(), PacketProfileLoggertIdToString(), PcapDetermineDirectoryOrFile(), PcapFileGlobalInit(), PcapLogProfileSetup(), PerCentEncodingMatch(), PmqSetup(), PoolGet(), PoolInit(), PoolPrintSaturation(), PoolThreadInit(), ReceiveAFPThreadInit(), ReceiveErfDagThreadInit(), ReceiveErfFileThreadInit(), ReceiveNFQThreadInit(), ReceivePfringThreadInit(), RegisterModbusParsers(), ROHashInit(), ROHashInitFinalize(), ROHashInitQueueValue(), RunmodeAutoFpCreatePickupQueuesString(), RunModeIdsNetmapRegister(), RunModeIdsNflogRegister(), RunModeIdsPcapRegister(), RunModeIdsPfringRegister(), RunModeSetLiveCaptureAutoFp(), RunModeUnixSocketGetDefaultMode(), SCACBSInitCtx(), SCACBSInitThreadCtx(), SCACBSPreparePatterns(), SCACInitCtx(), SCACInitThreadCtx(), SCACPreparePatterns(), SCACTileInitCtx(), SCACTileInitThreadCtx(), SCACTilePreparePatterns(), SCAsn1CtxDestroy(), SCAsn1CtxNew(), SCClassConfAllocClasstype(), SCLogAddFDFilter(), SCLogAddToFGFFileList(), SCLogAddToFGFFuncList(), SCLogAddToFGFLineList(), SCLogAllocLogInitData(), SCLogAllocLogOPBuffer(), SCLogCheckFDFilterEntry(), SCLogInitLogModule(), SCLogLoadConfig(), SCProfilingInit(), SCProfilingKeywordInitCounters(), SCProfilingKeywordThreadSetup(), SCProfilingKeywordUpdateCounter(), SCProfilingPrefilterInitCounters(), SCProfilingPrefilterThreadSetup(), SCProfilingPrefilterUpdateCounter(), SCProfilingRuleInitCounters(), SCProfilingRulesGlobalInit(), SCProfilingRuleThreadSetup(), SCProfilingRuleUpdateCounter(), SCRadixCreateRadixTree(), SCRadixPrintTree(), SCRadixReleaseRadixTree(), SCRConfAllocSCRConfReference(), SCThresholdConfInitContext(), SigAddressPrepareStage1(), SigAlloc(), SigGroupHeadBuildMatchArray(), SigGroupHeadBuildNonPrefilterArray(), SigGroupHeadInitDataFree(), SigGroupHeadStore(), SigMatchAlloc(), SigParseApplyDsizeToContent(), SMTPProcessDataChunk(), SMTPStateAlloc(), SRepInit(), SRepLoadFileFromFD(), SRepResetVersion(), SSLVersionToString(), StatsInit(), StatsSetUI64(), StorageAllocById(), StorageFinalize(), StorageFree(), StorageRegister(), StreamTcpReassembleGetMemcap(), StreamTcpReassembleInitThreadCtx(), StreamTcpSessionPktFree(), StreamTcpThreadInit(), SupportFastPatternForSigMatchList(), TagHostHasTag(), TcpSackCompare(), TLSGetIPInformations(), TmModuleDecodeNetmapRegister(), TmqhInputFlow(), TmqhOutputFlowSetupCtx(), TmSlotSetFuncAppend(), TmThreadCreate(), TmThreadInitMC(), Unified2AlertInitCtx(), Unified2AlertThreadInit(), UnixSocketPcapFile(), UTHBuildFlow(), UTHBuildPacketArrayFromEth(), UTHBuildPacketIPV6Real(), ValidateIPV4Address(), ValidateIPV6Address(), and VerdictIPFWThreadInit().

#define SCMallocAligned (   a,
 
)
Value:
({ \
void *ptrmem = NULL; \
\
int _r = posix_memalign(&ptrmem, (b), (a)); \
if (_r != 0 || ptrmem == NULL) { \
if (ptrmem != NULL) { \
free(ptrmem); \
ptrmem = NULL; \
} \
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
SCLogError(SC_ERR_MEM_ALLOC, "SCMallocAligned(posix_memalign) failed: %s, while trying " \
"to allocate %"PRIuMAX" bytes, alignment %"PRIuMAX, strerror(errno), (uintmax_t)a, (uintmax_t)b); \
SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \
exit(EXIT_FAILURE); \
} \
} \
(void*)ptrmem; \
})
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:294
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
Definition: util-atomic.h:192

wrapper for allocing aligned mem

Parameters
asize
balignement

Definition at line 363 of file util-mem.h.

Referenced by FlowInitConfig(), HostInitConfig(), IPPairInitConfig(), PrefilterAppendEngine(), PrefilterAppendPayloadEngine(), PrefilterAppendTxEngine(), and PrefilterSetupRuleGroup().

#define SCRealloc (   x,
 
)
Value:
({ \
void *ptrmem = NULL; \
\
ptrmem = realloc((x), (a)); \
if (ptrmem == NULL) { \
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
SCLogError(SC_ERR_MEM_ALLOC, "SCRealloc failed: %s, while trying " \
"to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)(a)); \
SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \
exit(EXIT_FAILURE); \
} \
} \
(void*)ptrmem; \
})
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:294
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
Definition: util-atomic.h:192

Definition at line 238 of file util-mem.h.

Referenced by AppLayerDecoderEventsSetEventRaw(), DetectBufferTypeGetByIdTransforms(), DetectFilestoreRegister(), DetectFlowbitsAnalyze(), FTPMemcapGlobalCounter(), HTPRealloc(), HttpHeaderExpandBuffer(), HttpHeaderThreadDataFree(), InspectionBufferCheckAndExpand(), InspectionBufferMultipleForListGet(), Ja3BufferFree(), MemBufferExpand(), MpmACBSRegister(), MpmAddPattern(), MpmFactoryRegisterMpmCtxProfile(), NFQParseAndRegisterQueues(), PoolThreadExpand(), PrefilterAddSidsResize(), printUUID(), RegisterModbusParsers(), RuleMatchCandidateTxArrayFree(), RunModeRegisterNewRunMode(), SCRadixAddKeyIPV6String(), SCRadixReleaseRadixTree(), SCThresholdConfInitContext(), SigGroupHeadStore(), SigMatchAppendSMToList(), SMTPProcessDataChunk(), SSLVersionToString(), StreamTcpReassembleGetMemcap(), TmqhInputFlow(), and TmThreadsRegisterThread().

#define SCStrdup (   a)
Value:
({ \
char *ptrmem = NULL; \
\
ptrmem = strdup((a)); \
if (ptrmem == NULL) { \
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
size_t _scstrdup_len = strlen((a)); \
SCLogError(SC_ERR_MEM_ALLOC, "SCStrdup failed: %s, while trying " \
"to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)_scstrdup_len); \
SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \
exit(EXIT_FAILURE); \
} \
} \
(void*)ptrmem; \
})
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:294
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
Definition: util-atomic.h:192

Definition at line 268 of file util-mem.h.

Referenced by ConfLoadCompleteIncludePath(), ConfNodeDump(), ConfNodeIsSequence(), ConfSet(), ConfSetFinal(), ConfSetFromString(), DecodeRegisterPerfCounters(), DetectAddressMapFree(), DetectAddressParseString(), DetectAppLayerEventRegister(), DetectAsn1Register(), DetectByteExtractDoMatch(), DetectBytejumpDoMatch(), DetectBytetestDoMatch(), DetectCipServiceRegister(), DetectCsumRegister(), DetectDceOpnumRegister(), DetectDetectionFilterRegister(), DetectFlowintMatch(), DetectFlowvarMatch(), DetectIsdataatRegister(), DetectLoadCompleteSigPath(), DetectLuaRegister(), DetectMetadataHashFree(), DetectMsgRegister(), DetectPortListsAreEqual(), DetectReferenceFree(), DetectSshSoftwareVersionRegister(), DetectSshVersionRegister(), DetectSslVersionRegister(), DetectThresholdRegister(), DetectTlsRegister(), DetectTlsVersionRegister(), IPOnlyCIDRListFree(), LiveRegisterDevice(), LiveRegisterDeviceName(), NoWinDivertSupportExit(), OutputJsonRegister(), PcapDetermineDirectoryOrFile(), PcapFileGlobalInit(), ReceivePfringThreadInit(), RegisterAllModules(), RunModeDispatch(), RunModeIdsPfringRegister(), RunModeRegisterNewRunMode(), RunModeUnixSocketGetDefaultMode(), SCClassConfAllocClasstype(), SCClassConfDeInitContext(), SCConfLogOpenGeneric(), SCHInfoAddHostOSInfo(), SCLogAddFDFilter(), SCLogAddToFGFFileList(), SCLogAddToFGFFuncList(), SCLogAllocLogOPBuffer(), SCLogLoadConfig(), SCProtoNameInit(), SCRadixPrintTree(), SCRConfAllocSCRConfReference(), SCRConfDeInitContext(), SigMatchListSMBelongsTo(), SigStringAlloc(), SRepLoadFileFromFD(), SSLVersionToString(), TmqCreateQueue(), TmqhOutputFlowSetupCtx(), TmThreadSetGroupName(), Unified2AlertInitCtx(), and VarNameStoreSetupStaging().

#define SCStrndup (   a,
 
)
Value:
({ \
char *ptrmem = NULL; \
size_t _len = (b); \
\
size_t _scstrndup_len = _len + 1; \
ptrmem = (char *)malloc(_scstrndup_len); \
if (ptrmem == NULL) { \
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
SCLogError(SC_ERR_MEM_ALLOC, "SCStrndup failed: %s, while trying " \
"to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)_scstrndup_len); \
SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \
exit(EXIT_FAILURE); \
} \
} else { \
strlcpy(ptrmem, (a), _len); \
*(ptrmem + _len) = '\0'; \
} \
(void*)ptrmem; \
})
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: util-strlcpyu.c:43
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:294
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
Definition: util-atomic.h:192

Definition at line 285 of file util-mem.h.

Referenced by DetectGeoipRegister().

Function Documentation

SC_ATOMIC_EXTERN ( unsigned  int,
engine_stage   
)