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 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

Utility Macros for memory management

Todo:
Add wrappers for functions that allocate/free memory here. Currently we have malloc, calloc, realloc, strdup 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:193

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

Referenced by AlertFastLogInitCtx(), AppLayerExpectationCreate(), AppLayerParserStreamTruncated(), BypassedFlowUpdate(), BytesToString(), ConfNodeNew(), DCERPCInit(), DefragInitConfig(), DefragTrackerFreeFrags(), DetectAddressMapFree(), DetectAppLayerInspectEngineRegister2(), DetectAppLayerMpmRegister(), DetectAppLayerMpmRegister2(), DetectAppLayerMpmRegisterByParentId(), DetectBase64DecodeDoMatch(), DetectBufferTypeGetByIdTransforms(), DetectBufferTypeMaxId(), DetectContentDataParse(), DetectEngineAppInspectionEngine2Signature(), DetectEngineMultiTenantSetup(), DetectEngineResetMaxSigId(), DetectLoaderQueueTask(), DetectLoadersInit(), DetectMpmInitializeAppMpms(), DetectMpmSetupAppMpms(), DetectNfsProcedureRegister(), DetectNfsVersionRegister(), DetectParseRegexAddToFreeList(), DetectPcrePayloadMatch(), DetectPktvarRegister(), DetectRegisterThreadCtxGlobalFuncs(), DetectSslVersionRegister(), DetectTlsValidityRegister(), DetectTlsVersionRegister(), DetectVarStoreMatch(), DetectVarStoreMatchKeyValue(), DNP3FreeObjectPointList(), DNP3PointListAlloc(), FlowVarAddIdValue(), FlowVarAddKeyValue(), FTPMemcapGlobalCounter(), HTPCalloc(), HttpHeaderThreadDataInit(), InspectionBufferApplyTransforms(), InspectionBufferInit(), isAndX(), Ja3BufferInit(), LiveRegisterDevice(), LiveRegisterDeviceName(), LogCustomFormatAlloc(), LogCustomFormatNodeAlloc(), LogHttpLogInitCtx(), LogStatsLogThreadDeinit(), LogTcpDataLogInitCtx(), MimeDecAddEntity(), MpmStorePrepareBuffer(), NapatechGetCurrentStats(), NapatechPacketLoopZC(), NapatechStreamThreadInit(), NFQParseAndRegisterQueues(), NoWinDivertSupportExit(), OutputJsonRegister(), OutputLoggerThreadInit(), OutputRegisterFiledataModule(), OutputRegisterFiledataSubModule(), OutputRegisterFileModule(), OutputRegisterFileRotationFlag(), OutputRegisterFileSubModule(), OutputRegisterFlowModule(), OutputRegisterFlowSubModule(), OutputRegisterPacketModule(), OutputRegisterPacketSubModule(), OutputRegisterRootLogger(), OutputRegisterStatsModule(), OutputRegisterStatsSubModule(), OutputRegisterStreamingModule(), OutputRegisterStreamingSubModule(), PacketCallocExtPkt(), PatternMatchPrepareGroup(), PcapDetermineDirectoryOrFile(), PktVarAdd(), PktVarAddKeyValue(), PoolInit(), PrefilterGenericMpmRegister(), PrefilterInit(), PrefilterMpmFiledataRegister(), printUUID(), 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 236 of file util-mem.h.

Referenced by __attribute__(), AFPGetLinkType(), AFPIsFanoutSupported(), AlertFastLogInitCtx(), AlertFastLogThreadDeinit(), AlertFastLogThreadInit(), AppLayerDecoderEventsFreeEvents(), AppLayerDestroyCtxThread(), AppLayerExpectationCreate(), AppLayerExpectationGetDataId(), AppLayerParserStateFree(), AppLayerParserThreadCtxFree(), AppLayerProtoDetectDestroyCtxThread(), BloomFilterCountingFree(), BloomFilterCountingInit(), BloomFilterFree(), BloomFilterInit(), BoyerMooreCtxDeInit(), BypassedFlowUpdate(), 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(), DetectDceGetState(), DetectDceIfaceRegister(), DetectDceOpnumRegister(), DetectDetectionFilterRegister(), DetectDsizeRegister(), DetectEngineAppInspectionEngineSignatureFree(), DetectEngineCtxFree(), DetectEngineCtxInitWithPrefix(), DetectEngineEventRegister(), DetectEngineIPOnlyThreadDeinit(), DetectEngineMultiTenantSetup(), DetectEngineResetMaxSigId(), DetectEngineStateFree(), DetectEngineThreadCtxInit(), DetectEnipCommandRegister(), DetectFileextRegister(), DetectFilemagicRegister(), DetectFilenameRegister(), DetectFilesizeRegister(), DetectFilestorePostMatch(), 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(), DetectSshSoftwareVersionRegister(), DetectSshVersionRegister(), DetectSslStateRegister(), DetectSslVersionRegister(), DetectStreamSizeFree(), DetectStreamSizeRegister(), DetectTagDataFree(), DetectTagRegister(), DetectTemplate2Free(), DetectTemplate2Register(), DetectTemplateRegister(), DetectThresholdRegister(), DetectTlsRegister(), DetectTlsValidityRegister(), DetectTlsVersionRegister(), DetectTosRegister(), DetectTtlFree(), DetectUricontentRegister(), DetectUrilenFree(), DetectUrilenRegister(), DetectUrilenValidateContent(), DetectVarProcessListInternal(), DetectVarStoreMatch(), DetectWindowFree(), DetectWindowRegister(), DetectXbitFree(), DetectXbitMatchHost(), DetectXbitsRegister(), DNP3FreeObjectPoint(), DNP3FreeObjectPointList(), DNSSetEvent(), DNSStateFree(), EngineAnalysisFP(), EngineAnalysisRulesFailure(), EngineDone(), FileContainerFree(), FlowBitFree(), FlowFree(), FlowStorageRegister(), FlowVarFree(), FTPMemcapGlobalCounter(), HashListTableFree(), HashListTableInit(), HashListTableRemove(), HashTableAdd(), HashTableFree(), HashTableInit(), HashTableRemove(), HostClearMemory(), HostFree(), HostFreeStorage(), HtpConfigRestoreBackup(), HTPFree(), HTPFreeConfig(), HttpHeaderThreadDataFree(), ICMPv4GetCounterpart(), InspectionBufferApplyTransforms(), InspectionBufferFree(), IPOnlyCIDRListFree(), IPOnlyDeinit(), IPOnlyPrepare(), IPPairFree(), IPPairStorageRegister(), isAndX(), Ja3BufferAppendBuffer(), Ja3BufferFree(), 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(), NFQParseAndRegisterQueues(), 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(), PoolThreadFree(), PoolThreadGrow(), PrefilterGenericMpmRegister(), PrefilterInit(), PrefilterSetupRuleGroup(), printUUID(), ReceiveAFPThreadDeinit(), ReceiveAFPThreadInit(), ReceiveErfDagThreadInit(), ReceiveNFQThreadDeinit(), ReceivePcapThreadInit(), ReceivePfringThreadDeinit(), ReceivePfringThreadInit(), RegisterDNP3Parsers(), RegisterModbusParsers(), RetrieveFPForSig(), ROHashFree(), ROHashInitFinalize(), RuleMatchCandidateTxArrayFree(), RunModeDispatch(), RunModeErfFileAutoFp(), RunModeFilePcapAutoFp(), RunModeIdsAFPRegister(), RunModeIdsNetmapRegister(), RunModeIdsNflogRegister(), RunModeIdsPcapRegister(), RunModeIdsPfringRegister(), RunModeRegisterNewRunMode(), RunModeSetIPSAutoFp(), RunModeSetLiveCaptureAutoFp(), RunModeTileMpipeRegister(), 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(), SigGroupBuild(), 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 302 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:193

Definition at line 174 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(), DetectEngineInspectBufferGeneric(), DetectEngineIPOnlyThreadInit(), DetectEngineResetMaxSigId(), DetectEngineStateAlloc(), DetectEngineThreadCtxInit(), DetectEnipCommandRegister(), DetectFileextRegister(), DetectFilemagicRegister(), DetectFilenameRegister(), DetectFilesizeRegister(), DetectFilestorePostMatch(), 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(), DetectTemplate2Register(), DetectTemplateRegister(), DetectThresholdRegister(), DetectTlsRegister(), DetectTlsValidityRegister(), DetectTosRegister(), DetectTtlRegister(), DetectUricontentRegister(), DetectUrilenRegister(), DetectWindowRegister(), DetectXbitFree(), DetectXbitMatchHost(), DetectXbitsRegister(), DNSSetEvent(), DNSStateAlloc(), DNSStoreAnswerInState(), DNSStoreQueryInState(), EngineAnalysisFP(), EngineAnalysisRulesFailure(), 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(), 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(), ReceivePcapThreadInit(), ReceivePfringThreadInit(), RegisterModbusParsers(), ROHashInit(), ROHashInitFinalize(), ROHashInitQueueValue(), RunmodeAutoFpCreatePickupQueuesString(), RunModeIdsNetmapRegister(), RunModeIdsNflogRegister(), RunModeIdsPcapRegister(), RunModeIdsPfringRegister(), RunModeSetLiveCaptureAutoFp(), RunModeTileMpipeRegister(), 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(), SRepDestroy(), 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:193

wrapper for allocing aligned mem

Parameters
asize
balignement

Definition at line 277 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:193

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

Referenced by AppLayerDecoderEventsSetEventRaw(), DetectBufferTypeGetByIdTransforms(), DetectFilestorePostMatch(), DetectFlowbitsAnalyze(), FTPMemcapGlobalCounter(), HTPRealloc(), HttpHeaderExpandBuffer(), HttpHeaderThreadDataFree(), InspectionBufferCheckAndExpand(), InspectionBufferMultipleForListGet(), Ja3BufferFree(), MemBufferExpand(), MpmACBSRegister(), MpmAddPattern(), MpmFactoryRegisterMpmCtxProfile(), PoolThreadGrow(), 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:193

Definition at line 220 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(), RunModeDispatch(), RunModeIdsPfringRegister(), RunModeRegisterNewRunMode(), RunModeTileMpipeRegister(), RunModeUnixSocketGetDefaultMode(), SCClassConfAllocClasstype(), SCClassConfDeInitContext(), SCConfLogOpenGeneric(), SCHInfoAddHostOSInfo(), SCLogAddFDFilter(), SCLogAddToFGFFileList(), SCLogAddToFGFFuncList(), SCLogAllocLogOPBuffer(), SCProtoNameInit(), SCRadixPrintTree(), SCRConfAllocSCRConfReference(), SCRConfDeInitContext(), SigParse(), SigStringAlloc(), SRepLoadFileFromFD(), SSLVersionToString(), TmqCreateQueue(), TmqhOutputFlowSetupCtx(), TmThreadSetGroupName(), Unified2AlertInitCtx(), and VarNameStoreSetupStaging().

Function Documentation

SC_ATOMIC_EXTERN ( unsigned  int,
engine_stage   
)