]> git.cworth.org Git - mnemon/commitdiff
Fix giant memory waste in menmon_get_bin
authorCarl Worth <cworth@cworth.org>
Tue, 17 Apr 2007 22:04:46 +0000 (15:04 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 17 Apr 2007 22:04:46 +0000 (15:04 -0700)
We were doubling the storage every time we failed to find a bin
present, whether or not we actually needed any more storage (oops!).

mnemon.c

index 737298ed045f4877765118845e2626050ec816bc..45e09308e53f017bfc63905463c1be7469ee387d 100644 (file)
--- a/mnemon.c
+++ b/mnemon.c
@@ -366,7 +366,8 @@ mnemon_get_bin (mnemon_t    *mnemon,
        else if (mnemon->bins[i].count > count)
            break;
 
-    mnemon_bins_grow (mnemon);
+    if (mnemon->num_bins == mnemon->bins_size)
+       mnemon_bins_grow (mnemon);
 
     bin = &mnemon->bins[i];