]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Some cleanups in isc mem code (#38896)
authorMukund Sivaraman <muks@isc.org>
Fri, 27 Mar 2015 17:39:28 +0000 (23:09 +0530)
committerMukund Sivaraman <muks@isc.org>
Fri, 27 Mar 2015 17:42:11 +0000 (23:12 +0530)
CHANGES
lib/isc/mem.c

diff --git a/CHANGES b/CHANGES
index fbcc8321d2d85eed21c9aa33924ea27191078b26..e8744e692eb6923b474e00b788a30e9295bc0be6 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+4091.  [cleanup]       Some cleanups in isc mem code. [RT #38896]
+
 4090.  [bug]           Fix a crash while parsing malformed CAA RRs in
                        presentation format, i.e., from text such as
                        from master files. Thanks to John Van de
index 669ea2a3763b4db35893c6eb0ab603b9c0772a84..d82e245638da822e2a4928786cb6b77cde909e22 100644 (file)
@@ -649,7 +649,7 @@ mem_getunlocked(isc__mem_t *ctx, size_t size) {
        size_t new_size = quantize(size);
        void *ret;
 
-       if (size >= ctx->max_size || new_size >= ctx->max_size) {
+       if (new_size >= ctx->max_size) {
                /*
                 * memget() was called on something beyond our upper limit.
                 */
@@ -730,7 +730,7 @@ static inline void
 mem_putunlocked(isc__mem_t *ctx, void *mem, size_t size) {
        size_t new_size = quantize(size);
 
-       if (size == ctx->max_size || new_size >= ctx->max_size) {
+       if (new_size >= ctx->max_size) {
                /*
                 * memput() called on something beyond our upper limit.
                 */
@@ -1067,11 +1067,17 @@ destroy(isc__mem_t *ctx) {
 
        if (ctx->checkfree) {
                for (i = 0; i <= ctx->max_size; i++) {
+                       if (ctx->stats[i].gets != 0U) {
+                               fprintf(stderr,
+                                       "Failing assertion due to probable "
+                                       "leaked memory in context %p (\"%s\") "
+                                       "(stats[%u].gets == %lu).\n",
+                                       ctx, ctx->name, i, ctx->stats[i].gets);
 #if ISC_MEM_TRACKLINES
-                       if (ctx->stats[i].gets != 0U)
                                print_active(ctx, stderr);
 #endif
-                       INSIST(ctx->stats[i].gets == 0U);
+                               INSIST(ctx->stats[i].gets == 0U);
+                       }
                }
        }