pike.git
/
src
/
constants.c
version
»
Context lines:
10
20
40
80
file
none
3
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)
-
BLOCK
_
ALLOC
_
FILL
_PAGES(callable,2)
+
#include "block
_
allocator.h"
+
static struct block
_
allocator callable
_
allocator
+
= BA_INIT_
PAGES(
sizeof(struct
callable
)
,
2)
;
-
+
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);
+
}
+
void free_all_callable_blocks() {
+
ba_destroy(&callable_allocator);
+
}
+
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) {
-
struct callable *f=
alloc
_callable();
+
struct callable *f=
(struct callable*)ba_
alloc
(&callable
_
allocator);
+
#ifdef PIKE_DEBUG
+
DOUBLELINK(first_
callable
, f
);
+
#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
pike.git/src/constants.c:206:
visit_string_ref (c->name, REF_TYPE_NORMAL); } /* Looks like the c->prog isn't refcounted..? */ /* visit_program_ref (c->prog, REF_TYPE_NORMAL); */ } #ifdef PIKE_DEBUG void present_constant_profiling(void) {
-
struct callable
_block
*
b
;
-
size_t e;
-
for(
b
=
callable
_
blocks
;
b
;
b=b->next)
-
{
-
for(e
=
0;e<NELEM(b->x);e++)
-
{
-
if(b
->
x[e].name
)
-
{
-
fprintf(stderr,"%010ld @E@: %s\n",
b
->
x[e].
runs,
b
->
x[e].
name->str);
+
struct callable *
c
;
+
for
(c
=
first_
callable;
c
;
c
=
c
->
next
) {
+
fprintf(stderr,"%010ld @E@: %s\n",
c
->runs,
c
->name->str);
} }
-
}
-
}
+
#endif void init_builtin_constants(void) { builtin_constants = allocate_mapping(300); } void exit_builtin_constants(void) { #ifdef DO_PIKE_CLEANUP if(builtin_constants) { free_mapping(builtin_constants); builtin_constants=0; } #endif }