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.89 2008/08/27 20:52:35 grubba Exp $ + || $Id$   */      #undef PRE_INIT_BLOCK   #undef DO_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
pike.git/src/block_alloc.h:32:   /* Note: The block_alloc mutex is held while PRE_INIT_BLOCK runs. */   #define PRE_INIT_BLOCK(X)   #define INIT_BLOCK(X)   #define EXIT_BLOCK(X)   #define COUNT_BLOCK(X)   #define COUNT_OTHER()   #define DMALLOC_DESCRIBE_BLOCK(X)   #define BLOCK_ALLOC_HSIZE_SHIFT 2   #define MAX_EMPTY_BLOCKS 4 /* Must be >= 1. */    - #ifndef BLOCK_ALLOC_USED - #define BLOCK_ALLOC_USED DO_IF_DMALLOC(real_used) DO_IF_NOT_DMALLOC(used) - #endif -  +    #if defined (DMALLOC_BLOCK_BACKLOG) && defined (DEBUG_MALLOC)   #define DO_IF_BLOCK_BACKLOG(X) X   #define DO_IF_NOT_BLOCK_BACKLOG(X) -  + #define BLOCK_ALLOC_USED real_used   #else   #define DO_IF_BLOCK_BACKLOG(X)   #define DO_IF_NOT_BLOCK_BACKLOG(X) X -  + #define BLOCK_ALLOC_USED used   #endif      /* Invalidate the block as far as possible if running with dmalloc.    */   #define DO_PRE_INIT_BLOCK(X) do { \    DO_IF_DMALLOC(MEMSET((X), 0x55, sizeof(*(X)))); \    PRE_INIT_BLOCK(X); \    } while (0)      #ifndef PIKE_HASH_T
pike.git/src/block_alloc.h:102:   #endif      #define BLOCK_ALLOC(DATA,BSIZE) \    \   struct PIKE_CONCAT(DATA,_block) \   { \    struct PIKE_CONCAT(DATA,_block) *next; \    struct PIKE_CONCAT(DATA,_block) *prev; \    struct DATA *PIKE_CONCAT3(free_,DATA,s); \    INT32 used; \ -  DO_IF_DMALLOC(INT32 real_used;) \ +  DO_IF_BLOCK_BACKLOG (INT32 real_used;) \    struct DATA x[BSIZE]; \   }; \   struct PIKE_CONCAT(DATA,_context) \   { \    struct PIKE_CONCAT(DATA,_context) *next; \    struct PIKE_CONCAT(DATA, _block) *blocks, *free_blocks; \    INT32 num_empty_blocks; \   }; \    \   static struct PIKE_CONCAT(DATA,_context) *PIKE_CONCAT(DATA,_ctxs)=0; \
pike.git/src/block_alloc.h:164:    malloc(sizeof(struct PIKE_CONCAT(DATA,_block))); \    if(!n) \    { \    fprintf(stderr,"Fatal: out of memory.\n"); \    exit(17); \    } \    if((n->next=PIKE_CONCAT(DATA,_blocks))) \    n->next->prev=n; \    n->prev=NULL; \    n->used=0; \ -  DO_IF_DMALLOC(n->real_used = 0); \ +  DO_IF_BLOCK_BACKLOG (n->real_used = 0); \    PIKE_CONCAT(DATA,_blocks)=n; \    PIKE_CONCAT(DATA,_free_blocks)=n; \    \    DO_PRE_INIT_BLOCK( n->x ); \    n->x[0].BLOCK_ALLOC_NEXT=NULL; \    for(e=1;e<(BSIZE);e++) \    { \    DO_PRE_INIT_BLOCK( (n->x+e) ); \    n->x[e].BLOCK_ALLOC_NEXT=(void *)&n->x[e-1]; \    } \
pike.git/src/block_alloc.h:196:    PIKE_CONCAT(alloc_more_,DATA)(); \    blk = PIKE_CONCAT(DATA,_blocks); \    blk->BLOCK_ALLOC_USED++; \    } \    DO_IF_DEBUG( \    else if (PIKE_CONCAT(DATA,_free_blocks) == (void *)-1) \    Pike_fatal("Block alloc " #DATA " not initialized.\n"); \    ) \    else if(!blk->BLOCK_ALLOC_USED++) \    --PIKE_CONCAT3(num_empty_,DATA,_blocks); \ -  DO_IF_DMALLOC(blk->used++); \ +  DO_IF_BLOCK_BACKLOG (blk->used++); \    \    tmp = blk->PIKE_CONCAT3(free_,DATA,s); \    /* Mark the new block as available. */ \    PIKE_MEM_RW(*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()); \    ) \
pike.git/src/block_alloc.h:292:    while (blk && ((char *)d < (char *)blk || \    (char *)d >= (char *)(blk->x+(BSIZE)))) \    blk = blk->next; \    } \    if (blk) { \    if (!dmalloc_check_allocated (d, 0)) { \    debug_malloc_dump_references(d, 0, 2, 0); \    Pike_fatal ("really_free_" TOSTR(DATA) " called with " \    "unknown pointer %p (probably already freed)\n", d); \    } \ -  blk->used--; \ +     dmalloc_mark_as_free(d, 1); \    DO_IF_BLOCK_BACKLOG({ \    struct DATA *d2 = \    PIKE_CONCAT(DATA,s_to_free)[PIKE_CONCAT(DATA,s_to_free_ptr)]; \ -  +  blk->used--; \    PIKE_MEM_NA(*d); \    PIKE_CONCAT(DATA,s_to_free)[PIKE_CONCAT(DATA,s_to_free_ptr)] = d; \    PIKE_CONCAT(DATA,s_to_free_ptr) = \    (PIKE_CONCAT(DATA,s_to_free_ptr) + 1) % \    NELEM(PIKE_CONCAT(DATA,s_to_free)); \    if ((d = d2)) \    PIKE_MEM_WO(*d); \    else \    return; \    }); \