From: Victor Julien Date: Fri, 25 Mar 2016 11:27:11 +0000 (+0100) Subject: detect-address: remove debug mem counters X-Git-Tag: suricata-3.1RC1~302 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9bd8197009ff36ffb7dbf8f6362f6f8570b0bd2b;p=thirdparty%2Fsuricata.git detect-address: remove debug mem counters --- diff --git a/src/detect-engine-address.c b/src/detect-engine-address.c index c3ce599d3f..30bd5b7e72 100644 --- a/src/detect-engine-address.c +++ b/src/detect-engine-address.c @@ -54,18 +54,6 @@ static int DetectAddressCut(DetectEngineCtx *, DetectAddress *, DetectAddress *, DetectAddress **); int DetectAddressMergeNot(DetectAddressHead *gh, DetectAddressHead *ghn); -/** memory usage counters - * \todo not MT safe */ -#ifdef DEBUG -static uint32_t detect_address_group_memory = 0; -static uint32_t detect_address_group_init_cnt = 0; -static uint32_t detect_address_group_free_cnt = 0; - -static uint32_t detect_address_group_head_memory = 0; -static uint32_t detect_address_group_head_init_cnt = 0; -static uint32_t detect_address_group_head_free_cnt = 0; -#endif - /** * \brief Creates and returns a new instance of a DetectAddress. * @@ -79,11 +67,6 @@ DetectAddress *DetectAddressInit(void) return NULL; memset(ag, 0, sizeof(DetectAddress)); -#ifdef DEBUG - detect_address_group_memory += sizeof(DetectAddress); - detect_address_group_init_cnt++; -#endif - return ag; } @@ -107,10 +90,6 @@ void DetectAddressFree(DetectAddress *ag) } ag->sh = NULL; -#ifdef DEBUG - detect_address_group_memory -= sizeof(DetectAddress); - detect_address_group_free_cnt++; -#endif SCFree(ag); return; @@ -140,42 +119,6 @@ DetectAddress *DetectAddressCopy(DetectAddress *orig) return ag; } -/** - * \brief Prints the memory statistics for the detection-engine-address section. - */ -void DetectAddressPrintMemory(void) -{ -#ifdef DEBUG - SCLogDebug(" * Address group memory stats (DetectAddress %" PRIuMAX "):", - (uintmax_t)sizeof(DetectAddress)); - SCLogDebug(" - detect_address_group_memory %" PRIu32, - detect_address_group_memory); - SCLogDebug(" - detect_address_group_init_cnt %" PRIu32, - detect_address_group_init_cnt); - SCLogDebug(" - detect_address_group_free_cnt %" PRIu32, - detect_address_group_free_cnt); - SCLogDebug(" - outstanding groups %" PRIu32, - detect_address_group_init_cnt - detect_address_group_free_cnt); - SCLogDebug(" * Address group memory stats done"); - SCLogDebug(" * Address group head memory stats (DetectAddressHead %" PRIuMAX "):", - (uintmax_t)sizeof(DetectAddressHead)); - SCLogDebug(" - detect_address_group_head_memory %" PRIu32, - detect_address_group_head_memory); - SCLogDebug(" - detect_address_group_head_init_cnt %" PRIu32, - detect_address_group_head_init_cnt); - SCLogDebug(" - detect_address_group_head_free_cnt %" PRIu32, - detect_address_group_head_free_cnt); - SCLogDebug(" - outstanding groups %" PRIu32, - (detect_address_group_head_init_cnt - - detect_address_group_head_free_cnt)); - SCLogDebug(" * Address group head memory stats done"); - SCLogDebug(" X Total %" PRIu32 "\n", (detect_address_group_memory + - detect_address_group_head_memory)); -#endif - - return; -} - /** * \brief Used to check if a DetectAddress list contains an instance with * a similar DetectAddress. The comparison done is not the one that @@ -1485,11 +1428,6 @@ DetectAddressHead *DetectAddressHeadInit(void) return NULL; memset(gh, 0, sizeof(DetectAddressHead)); -#ifdef DEBUG - detect_address_group_head_init_cnt++; - detect_address_group_head_memory += sizeof(DetectAddressHead); -#endif - return gh; } @@ -1531,10 +1469,6 @@ void DetectAddressHeadFree(DetectAddressHead *gh) if (gh != NULL) { DetectAddressHeadCleanup(gh); SCFree(gh); -#ifdef DEBUG - detect_address_group_head_free_cnt++; - detect_address_group_head_memory -= sizeof(DetectAddressHead); -#endif } return; diff --git a/src/detect-engine-address.h b/src/detect-engine-address.h index b29cff1b4c..3b84f22577 100644 --- a/src/detect-engine-address.h +++ b/src/detect-engine-address.h @@ -26,7 +26,6 @@ /* prototypes */ void DetectAddressRegister (void); -void DetectAddressPrintMemory(void); DetectAddressHead *DetectAddressHeadInit(void); void DetectAddressHeadFree(DetectAddressHead *); diff --git a/src/detect-ipproto.c b/src/detect-ipproto.c index 3be710ac69..c0de5e95c1 100644 --- a/src/detect-ipproto.c +++ b/src/detect-ipproto.c @@ -9241,7 +9241,7 @@ static int DetectIPProtoTestSig1(void) uint16_t buflen = strlen((char *)buf); Packet *p = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_TCP); if (p == NULL) - goto end; + return 0; char *sigs[4]; sigs[0] = "alert ip any any -> any any " @@ -9268,8 +9268,6 @@ static int DetectIPProtoTestSig1(void) result = UTHGenericTest(&p, 1, sigs, sid, results, 4); UTHFreePacket(p); -end: - DetectAddressPrintMemory(); return result; } diff --git a/src/detect-rpc.c b/src/detect-rpc.c index dfaf5f3f6f..fe693deb19 100644 --- a/src/detect-rpc.c +++ b/src/detect-rpc.c @@ -585,7 +585,6 @@ cleanup: DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); DetectEngineCtxFree(de_ctx); - DetectAddressPrintMemory(); UTHFreePackets(&p, 1); end: return result; diff --git a/src/detect.c b/src/detect.c index 1642017945..f89649da97 100644 --- a/src/detect.c +++ b/src/detect.c @@ -8539,7 +8539,6 @@ static int SigTestMemory01 (void) DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); printf("@pre cleanup\n\n"); - DetectAddressPrintMemory(); DetectPortPrintMemory(); SigGroupCleanup(de_ctx); @@ -8547,7 +8546,6 @@ printf("@pre cleanup\n\n"); DetectEngineCtxFree(de_ctx); printf("@exit\n\n"); - DetectAddressPrintMemory(); DetectPortPrintMemory(); result = 1; @@ -8587,10 +8585,8 @@ printf("@cleanup\n\n"); DetectEngineCtxFree(de_ctx); printf("@exit\n\n"); - DetectAddressPrintMemory(); DetectPortPrintMemory(); printf("@exit\n\n"); - DetectAddressPrintMemory(); DetectPortPrintMemory(); result = 1; @@ -8634,7 +8630,6 @@ printf("@cleanup\n\n"); DetectEngineCtxFree(de_ctx); printf("@exit\n\n"); - DetectAddressPrintMemory(); DetectPortPrintMemory(); result = 1;