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.62 2003/02/24 20:00:52 grubba Exp $ + || $Id: block_alloc.h,v 1.63 2003/03/14 15:50:43 grubba 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   #undef MAX_EMPTY_BLOCKS   #undef BLOCK_ALLOC_FILL_PAGES   #undef PTR_HASH_ALLOC_FILL_PAGES   #undef PTR_HASH_ALLOC_FIXED_FILL_PAGES      /* Note: The block_alloc mutex is held while PRE_INIT_BLOCK runs. */   #define PRE_INIT_BLOCK(X)   #define INIT_BLOCK(X) -  + #ifdef DEBUG_MALLOC + #define EXIT_BLOCK(X) MEMSET((X), 0x55, sizeof(*(X))) + #else   #define EXIT_BLOCK(X) -  + #endif /* DEBUG_MALLOC */   #define COUNT_BLOCK(X)   #define COUNT_OTHER()   #define BLOCK_ALLOC_HSIZE_SHIFT 2   #define MAX_EMPTY_BLOCKS 4      #ifndef BLOCK_ALLOC_USED   #define BLOCK_ALLOC_USED DO_IF_DMALLOC(real_used) DO_IF_NOT_DMALLOC(used)   #endif      #ifndef PIKE_HASH_T
pike.git/src/block_alloc.h:179:    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); \ +  #DATA, d); \   } \   ) \    \   void PIKE_CONCAT(really_free_,DATA)(struct DATA *d) \   { \    struct PIKE_CONCAT(DATA,_block) *blk; \    \    EXIT_BLOCK(d); \    \    DO_IF_RUN_UNLOCKED(mt_lock(&PIKE_CONCAT(DATA,_mutex))); \
pike.git/src/block_alloc.h:241:    blk->prev = NULL; \    blk->next = PIKE_CONCAT(DATA,_blocks); \    blk->next->prev = blk; \    PIKE_CONCAT(DATA,_blocks) = blk; \    } \    if(PIKE_CONCAT(DATA,_free_blocks) == NULL) \    PIKE_CONCAT(DATA,_free_blocks) = blk; \    } \    \    d->BLOCK_ALLOC_NEXT = (void *)blk->PIKE_CONCAT3(free_,DATA,s); \ +  blk->PIKE_CONCAT3(free_,DATA,s)=d; \    PRE_INIT_BLOCK(d); \    /* Mark block as unavailable. */ \    PIKE_MEM_NA(*d); \ -  blk->PIKE_CONCAT3(free_,DATA,s)=d; \ +     \    if(!--blk->BLOCK_ALLOC_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; \