Branch: Tag:

2015-09-21

2015-09-21 18:20:39 by Arne Goedeke <el@laramies.com>

block_allocator: improved error messages

79:    * happens if ba_get_layout overflows    */    if (a->l.offset > l.offset || n < l.offset) { -  Pike_error("Overflow.\n"); +  Pike_error(msg_out_of_mem_2, a->l.offset);    }       if (l.alignment) {
129:    PIKE_MEMPOOL_CREATE(a);       if (a->l.alignment) { + #if PIKE_DEBUG    if (a->l.alignment & (a->l.alignment - 1))    Pike_fatal("Block allocator a->l.alignment is not a power of 2.\n");    if (block_size & (a->l.alignment-1))    Pike_fatal("Block allocator block size is not aligned.\n"); -  + #endif    a->l.doffset = PIKE_ALIGNTO(sizeof(struct ba_page), a->l.alignment);    } else {    a->l.doffset = sizeof(struct ba_page);
233:    }       if (a->size == (sizeof(a->pages)/sizeof(a->pages[0]))) { -  Pike_error("Out of memory.\n"); +  Pike_error(msg_out_of_mem_2, a->l.offset);    }    a->pages[a->size] = ba_alloc_page(a, a->size);    a->alloc = a->size;
335: Inside #if defined(PIKE_DEBUG)
  #ifdef PIKE_DEBUG    print_allocator(a);   #endif -  Pike_fatal("ptr %p not in any page.\n", ptr); +  Pike_error("Trying to free unknown block %p.\n", ptr);    }    PIKE_MEMPOOL_FREE(a, ptr, a->l.block_size);   }