pike.git / src / block_alloc.h

version» Context lines:

pike.git/src/block_alloc.h:1: - /* $Id: block_alloc.h,v 1.39 2001/10/06 12:04:08 hubbe Exp $ */ + /* $Id: block_alloc.h,v 1.40 2001/11/08 23:34:27 nilsson 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   #undef COUNT_OTHER -  + #undef BLOCK_ALLOC_HSIZE_SHIFT      #define PRE_INIT_BLOCK(X)   #define INIT_BLOCK(X)   #define EXIT_BLOCK(X)   #define COUNT_BLOCK(X)   #define COUNT_OTHER() -  + #define BLOCK_ALLOC_HSIZE_SHIFT 2      #ifdef PIKE_RUN_UNLOCKED   #include "threads.h"      /* Block Alloc UnLocked */   #define BA_UL(X) PIKE_CONCAT(X,_unlocked)   #define BA_STATIC static   #define BA_INLINE inline   #else   #define BA_UL(X) X
pike.git/src/block_alloc.h:67:    struct DATA *tmp; \    if(!PIKE_CONCAT3(free_,DATA,s)) \    PIKE_CONCAT(alloc_more_,DATA)(); \    DO_IF_DEBUG( \    else if (PIKE_CONCAT3(free_,DATA,s) == (struct DATA *)-1) \    fatal("Block alloc not initialized.\n"); \    ) \    \    tmp=PIKE_CONCAT3(free_,DATA,s); \    PIKE_CONCAT3(free_,DATA,s)=(struct DATA *)tmp->BLOCK_ALLOC_NEXT; \ -  DO_IF_DMALLOC( dmalloc_register(tmp,sizeof(struct DATA), DMALLOC_LOCATION()); )\ +  DO_IF_DMALLOC( \ +  dmalloc_unregister(tmp, 1); \ +  dmalloc_register(tmp,sizeof(struct DATA), DMALLOC_LOCATION()); \ +  ) \    INIT_BLOCK(tmp); \    return tmp; \   } \    \   DO_IF_RUN_UNLOCKED( \   struct DATA *PIKE_CONCAT(alloc_,DATA)(void) \   { \    struct DATA *ret; \    DO_IF_RUN_UNLOCKED(mt_lock(&PIKE_CONCAT(DATA,_mutex))); \    ret=PIKE_CONCAT3(alloc_,DATA,_unlocked)(); \
pike.git/src/block_alloc.h:129:    \   static void PIKE_CONCAT3(free_all_,DATA,_blocks_unlocked)(void) \   { \    struct PIKE_CONCAT(DATA,_block) *tmp; \    DO_IF_DMALLOC( \    for(tmp=PIKE_CONCAT(DATA,_blocks);tmp;tmp=tmp->next) \    { \    int tmp2; \    extern void dmalloc_check_block_free(void *p, char *loc); \    for(tmp2=0;tmp2<BSIZE;tmp2++) \ +  { \    dmalloc_check_block_free(tmp->x+tmp2, DMALLOC_LOCATION()); \ -  +  dmalloc_unregister(tmp->x+tmp2, 1); \ +  } \    } \    ) \    while((tmp=PIKE_CONCAT(DATA,_blocks))) \    { \    PIKE_CONCAT(DATA,_blocks)=tmp->next; \    free((char *)tmp); \    } \    PIKE_CONCAT(DATA,_blocks)=0; \    PIKE_CONCAT3(free_,DATA,s)=0; \   } \
pike.git/src/block_alloc.h:398:   } \    \   struct DATA *PIKE_CONCAT3(make_,DATA,_unlocked)(void *ptr, size_t hval) \   { \    struct DATA *p; \    \    DO_IF_DEBUG( if(!PIKE_CONCAT(DATA,_hash_table)) \    fatal("Hash table error!\n"); ) \    PIKE_CONCAT(num_,DATA)++; \    \ -  if(( PIKE_CONCAT(num_,DATA)>>2 ) >= \ +  if(( PIKE_CONCAT(num_,DATA)>>BLOCK_ALLOC_HSIZE_SHIFT ) >= \    PIKE_CONCAT(DATA,_hash_table_size)) \    { \    PIKE_CONCAT(DATA,_rehash)(); \    hval=(size_t)ptr; \    hval%=PIKE_CONCAT(DATA,_hash_table_size); \    } \    \    p=BA_UL(PIKE_CONCAT(alloc_,DATA))(); \    p->data=ptr; \    p->BLOCK_ALLOC_NEXT=PIKE_CONCAT(DATA,_hash_table)[hval]; \    PIKE_CONCAT(DATA,_hash_table)[hval]=p; \    return p; \   }