pike.git / src / block_alloc.h

version» Context lines:

pike.git/src/block_alloc.h:1:   /*   || 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.55 2002/12/01 00:57:32 mast Exp $ + || $Id: block_alloc.h,v 1.56 2002/12/01 02:51:51 mast Exp $   */      #undef PRE_INIT_BLOCK   #undef INIT_BLOCK   #undef EXIT_BLOCK   #undef BLOCK_ALLOC   #undef LOW_PTR_HASH_ALLOC   #undef PTR_HASH_ALLOC_FIXED   #undef PTR_HASH_ALLOC   #undef COUNT_BLOCK
pike.git/src/block_alloc.h:155:   }) \    \   DO_IF_DMALLOC( \   static void PIKE_CONCAT(check_free_,DATA)(struct DATA *d) \   { \    struct PIKE_CONCAT(DATA,_block) *tmp; \    for(tmp=PIKE_CONCAT(DATA,_blocks);tmp;tmp=tmp->next) \    { \    if( (char *)d < (char *)tmp) continue; \    if( (char *)d >= (char *)(tmp->x+(BSIZE))) continue; \ +  if ((char *) d - (char *) tmp->x != \ +  (d - tmp->x) * (ptrdiff_t) sizeof (struct DATA)) break; \    return; \    } \    Pike_fatal("really_free_%s called on non-block_alloc region (%p).\n", \    #DATA, d); \   } \   ) \    \   DO_IF_RUN_UNLOCKED( \   void PIKE_CONCAT3(really_free_,DATA,_unlocked)(struct DATA *d) \   { \
pike.git/src/block_alloc.h:206:    if(!--blk->used && \    ++PIKE_CONCAT3(num_empty_,DATA,_blocks) > MAX_EMPTY_BLOCKS) { \    if(blk == PIKE_CONCAT(DATA,_free_blocks)) { \    if((blk->prev->next = blk->next)) \    blk->next->prev = blk->prev; \    PIKE_CONCAT(DATA,_free_blocks) = blk->prev; \    } else { \    PIKE_CONCAT(DATA,_blocks) = blk->next; \    blk->next->prev = NULL; \    } \ +  DO_IF_DMALLOC({ \ +  size_t i; \ +  extern void dmalloc_check_block_free(void *p, char *loc); \ +  for (i = 0; i < (BSIZE); i++) { \ +  dmalloc_check_block_free(blk->x + i, DMALLOC_LOCATION()); \ +  dmalloc_unregister(blk->x + i, 1); \ +  } \ +  }); \    /* Mark meta-block as available, since libc will mess with it. */ \    PIKE_MEM_RW(*blk); \    free(blk); \    --PIKE_CONCAT3(num_empty_,DATA,_blocks); \    } \   }) \    \   void PIKE_CONCAT(really_free_,DATA)(struct DATA *d) \   { \    struct PIKE_CONCAT(DATA,_block) *blk; \
pike.git/src/block_alloc.h:258:    if(!--blk->used && \    ++PIKE_CONCAT3(num_empty_,DATA,_blocks) > MAX_EMPTY_BLOCKS) { \    if(blk == PIKE_CONCAT(DATA,_free_blocks)) { \    if((blk->prev->next = blk->next)) \    blk->next->prev = blk->prev; \    PIKE_CONCAT(DATA,_free_blocks) = blk->prev; \    } else { \    PIKE_CONCAT(DATA,_blocks) = blk->next; \    blk->next->prev = NULL; \    } \ +  DO_IF_DMALLOC({ \ +  size_t i; \ +  extern void dmalloc_check_block_free(void *p, char *loc); \ +  for (i = 0; i < (BSIZE); i++) { \ +  dmalloc_check_block_free(blk->x + i, DMALLOC_LOCATION()); \ +  dmalloc_unregister(blk->x + i, 1); \ +  } \ +  }); \    /* Mark meta-block as available, since libc will mess with it. */ \    PIKE_MEM_RW(*blk); \    free(blk); \    --PIKE_CONCAT3(num_empty_,DATA,_blocks); \    } \    DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \   } \    \   static void PIKE_CONCAT3(free_all_,DATA,_blocks_unlocked)(void) \   { \
pike.git/src/block_alloc.h:416:    { \    DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \    return 0; \    } \    \    PIKE_CONCAT3(make_,DATA,_unlocked)(ptr, hval); \    DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \    return 1; \   } \    \ + void PIKE_CONCAT(move_,DATA)(struct DATA *block, void *new_ptr) \ + { \ +  size_t hval = (size_t) block->PTR_HASH_ALLOC_DATA; \ +  DO_IF_RUN_UNLOCKED(mt_lock(&PIKE_CONCAT(DATA,_mutex))); \ +  hval %= PIKE_CONCAT(DATA,_hash_table_size); \ +  if (!PIKE_CONCAT3(really_low_find_,DATA,_unlocked)( \ +  block->PTR_HASH_ALLOC_DATA, hval)) \ +  Pike_fatal("The block to move wasn't found.\n"); \ +  DO_IF_DEBUG( \ +  if (PIKE_CONCAT(DATA,_hash_table)[hval] != block) \ +  Pike_fatal("Expected the block to be at the top of the hash chain.\n"); \ +  ); \ +  PIKE_CONCAT(DATA,_hash_table)[hval] = block->BLOCK_ALLOC_NEXT; \ +  block->PTR_HASH_ALLOC_DATA = new_ptr; \ +  hval = (size_t) new_ptr % PIKE_CONCAT(DATA,_hash_table_size); \ +  block->BLOCK_ALLOC_NEXT = PIKE_CONCAT(DATA,_hash_table)[hval]; \ +  PIKE_CONCAT(DATA,_hash_table)[hval] = block; \ +  DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \ + } \ +  \   int PIKE_CONCAT(remove_,DATA)(void *ptr) \   { \    struct DATA *p; \    size_t hval=(size_t)ptr; \    DO_IF_RUN_UNLOCKED(mt_lock(&PIKE_CONCAT(DATA,_mutex))); \    if(!PIKE_CONCAT(DATA,_hash_table)) \    { \    DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \    return 0; \    } \