pike.git / src / constants.c

version» Context lines:

pike.git/src/constants.c:61:    free_string(key);   }      PMOD_EXPORT void add_global_program(const char *name, struct program *p)   {    struct svalue s;    SET_SVAL(s, T_PROGRAM, 0, program, p);    low_add_constant(name, p?&s:NULL);   }    - #undef INIT_BLOCK - #define INIT_BLOCK(X) do { \ -  DO_IF_DEBUG (DOUBLELINK (first_callable, X)); \ -  } while (0) -  +    #undef EXIT_BLOCK   #define EXIT_BLOCK(X) do { \    DO_IF_DEBUG (DOUBLEUNLINK (first_callable, X)); \    free_type(X->type); \    free_string(X->name); \    X->name=0; \    EXIT_PIKE_MEMOBJ(X); \   }while(0)    -  + #ifndef PIKE_NEW_BLOCK_ALLOC + #undef INIT_BLOCK + #define INIT_BLOCK(X) do { \ +  DO_IF_DEBUG (DOUBLELINK (first_callable, X)); \ +  } while (0) +  +    BLOCK_ALLOC_FILL_PAGES(callable,2) -  + #else + #include "gjalloc.h" + static struct block_allocator callable_allocator +  = BA_INIT(sizeof(struct callable), 2*4096/sizeof(struct callable));    -  + void really_free_callable(struct callable * c) { +  EXIT_BLOCK(c); +  ba_free(&callable_allocator, c); + } + void count_memory_in_callables(size_t * num, size_t * size) { +  ba_count_all(&callable_allocator, num, size); + } + #endif +    int global_callable_flags=0;      /* Eats one ref to 'type' and 'name' */   PMOD_EXPORT struct callable *low_make_callable(c_fun fun,    struct pike_string *name,    struct pike_type *type,    int flags,    optimize_fun optimize,    docode_fun docode)   { -  + #ifndef PIKE_NEW_BLOCK_ALLOC    struct callable *f=alloc_callable(); -  + #else +  struct callable *f=(struct callable*)ba_alloc(&callable_allocator); + # ifdef PIKE_DEBUG +  DOUBLELINK(first_callable, f); + # endif + #endif    INIT_PIKE_MEMOBJ(f, T_STRUCT_CALLABLE);    f->function=fun;    f->name=name;    f->type=type;    f->prog=Pike_compiler->new_program;    f->flags=flags;    f->docode=docode;    f->optimize=optimize;    f->internal_flags = global_callable_flags;   #ifdef PIKE_DEBUG