Branch: Tag:

2002-11-20

2002-11-20 17:33:42 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Improved interaction with valgrind.

Rev: src/block_alloc.h:1.49

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: block_alloc.h,v 1.48 2002/11/19 13:53:48 mast Exp $ + || $Id: block_alloc.h,v 1.49 2002/11/20 17:33:42 grubba Exp $   */      #undef PRE_INIT_BLOCK
80:    PRE_INIT_BLOCK( (n->x+e) ); \    } \    n->PIKE_CONCAT3(free_,DATA,s)=&n->x[(BSIZE)-1]; \ +  /* Mark the new blocks as unavailable for now... */ \ +  PIKE_MEM_NA(&n->x, sizeof(n->x)); \   } \    \   BA_STATIC BA_INLINE struct DATA *BA_UL(PIKE_CONCAT(alloc_,DATA))(void) \
100:    --PIKE_CONCAT3(num_empty_,DATA,_blocks); \    \    tmp = blk->PIKE_CONCAT3(free_,DATA,s); \ +  /* Mark the new block as available. */ \ +  PIKE_MEM_RW(tmp, sizeof(*tmp)); \    if(!(blk->PIKE_CONCAT3(free_,DATA,s) = (void *)tmp->BLOCK_ALLOC_NEXT)) \    PIKE_CONCAT(DATA,_free_blocks) = blk->prev; \    DO_IF_DMALLOC( \    dmalloc_unregister(tmp, 1); \    dmalloc_register(tmp,sizeof(struct DATA), DMALLOC_LOCATION()); \    ) \ -  +  /* Mark the new block as available but uninitialized. */ \ +  PIKE_MEM_WO(tmp, sizeof(*tmp)); \    INIT_BLOCK(tmp); \    return tmp; \   } \
144:    blk = PIKE_CONCAT(DATA,_blocks); \    if((char *)d < (char *)blk || \    (char *)d >= (char *)(blk->x+(BSIZE))) { \ -  do \ +  do { \    blk = blk->next; \ -  while((char *)d < (char *)blk || \ +  } while((char *)d < (char *)blk || \    (char *)d >= (char *)(blk->x+(BSIZE))); \    if(blk == PIKE_CONCAT(DATA,_free_blocks)) \    PIKE_CONCAT(DATA,_free_blocks) = blk->prev; \
166:    dmalloc_mark_as_free(d, 1); ) \    d->BLOCK_ALLOC_NEXT = (void *)blk->PIKE_CONCAT3(free_,DATA,s); \    PRE_INIT_BLOCK(d); \ +  /* Mark block as unavailable. */ \ +  PIKE_MEM_NA(d, sizeof(*d)); \    blk->PIKE_CONCAT3(free_,DATA,s)=d; \    if(!--blk->used && \    ++PIKE_CONCAT3(num_empty_,DATA,_blocks) > MAX_EMPTY_BLOCKS) { \
177:    PIKE_CONCAT(DATA,_blocks) = blk->next; \    blk->next->prev = NULL; \    } \ +  /* Mark meta-block as available, since libc will mess with it. */ \ +  PIKE_MEM_RW(blk, sizeof(*blk)); \    free(blk); \    --PIKE_CONCAT3(num_empty_,DATA,_blocks); \    } \
214:    dmalloc_mark_as_free(d, 1); ) \    d->BLOCK_ALLOC_NEXT = (void *)blk->PIKE_CONCAT3(free_,DATA,s); \    PRE_INIT_BLOCK(d); \ +  /* Mark block as unavailable. */ \ +  PIKE_MEM_NA(d, sizeof(*d)); \    blk->PIKE_CONCAT3(free_,DATA,s)=d; \    if(!--blk->used && \    ++PIKE_CONCAT3(num_empty_,DATA,_blocks) > MAX_EMPTY_BLOCKS) { \
225:    PIKE_CONCAT(DATA,_blocks) = blk->next; \    blk->next->prev = NULL; \    } \ +  /* Mark meta-block as available, since libc will mess with it. */ \ +  PIKE_MEM_RW(blk, sizeof(*blk)); \    free(blk); \    --PIKE_CONCAT3(num_empty_,DATA,_blocks); \    } \
249:    while((tmp=PIKE_CONCAT(DATA,_blocks))) \    { \    PIKE_CONCAT(DATA,_blocks)=tmp->next; \ +  /* Mark meta-block as available, since libc will mess with it. */ \ +  PIKE_MEM_RW(tmp, sizeof(*tmp)); \    free((char *)tmp); \    } \    PIKE_CONCAT(DATA,_blocks)=0; \