]> git.ozlabs.org Git - ccan/blobdiff - ccan/alloc/alloc.c
alloc: fix uninitialized entry (thanks valgrind!)
[ccan] / ccan / alloc / alloc.c
index 693943aea140c881587020550525c1aa78571768..6cd96d8d8a3681713273f3ed45f8bcea59f49281 100644 (file)
@@ -35,7 +35,7 @@
  */
 
 /* We divide the pool into this many large pages (nearest power of 2) */
-#define MAX_LARGE_PAGES (1024UL)
+#define MAX_LARGE_PAGES (256UL)
 
 /* 32 small pages == 1 large page. */
 #define BITS_FROM_SMALL_TO_LARGE_PAGE 5
@@ -489,6 +489,8 @@ static unsigned long break_up_large_page(struct header *head,
 
        for (i = 1; i < SMALL_PAGES_PER_LARGE_PAGE; i++) {
                struct page_header *ph = from_pgnum(head, lpage + i, sp_bits);
+               /* Initialize this: huge_alloc reads it. */
+               ph->elements_used = 0;
                add_small_page_to_freelist(head, ph, sp_bits);
        }
 
@@ -509,49 +511,6 @@ static u16 get_small_page(struct header *head, unsigned long poolsize,
        return ret;
 }
 
-void where_is_page(struct header *head, struct page_header *where,
-                  unsigned int sp_bits)
-{
-       struct page_header *pg;
-       unsigned long off, bucket,
-               num_buckets = max_bucket(sp_bits + BITS_FROM_SMALL_TO_LARGE_PAGE);
-
-       for (off = head->small_free_list; off; off = pg->next) {
-               pg = from_pgnum(head, off, sp_bits);
-               if (pg == where) {
-                       printf("It's in the small free list\n");
-                       return;
-               }
-       }
-
-       for (off = head->large_free_list; off; off = pg->next) {
-               pg = from_pgnum(head, off, sp_bits);
-               if (pg == where) {
-                       printf("It's in the large free list\n");
-                       return;
-               }
-       }
-
-       for (bucket = 0; bucket < num_buckets; bucket++) {
-               for (off = head->bs[bucket].page_list; off; off = pg->next) {
-                       pg = from_pgnum(head, off, sp_bits);
-                       if (pg == where) {
-                               printf("It's in %lu bucket page list\n", bucket);
-                               return;
-                       }
-               }
-
-               for (off = head->bs[bucket].full_list; off; off = pg->next) {
-                       pg = from_pgnum(head, off, sp_bits);
-                       if (pg == where) {
-                               printf("It's in %lu bucket full list\n", bucket);
-                               return;
-                       }
-               }
-       }
-       printf("It's nowhere!\n");
-}
-
 static bool huge_allocated(struct header *head, unsigned long offset)
 {
        unsigned long i;