pike.git
/
src
/
builtin.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/builtin.cmod:21:
#include "threads.h" #include "module_support.h" #include "cyclic.h" #include "bignum.h" #include "main.h" #include "operators.h" #include "builtin_functions.h" #include "fsort.h" #include "port.h" #include "gc.h"
-
#include "block_
alloc
.h"
+
#include "block_
allocator
.h"
#include "pikecode.h" #include "opcodes.h" #include <ctype.h> #include <errno.h> #include <math.h> DECLARATIONS
pike.git/src/builtin.cmod:4135:
push_svalue(tmpargs+e); } } check_stack(depth * (args+1)); low_automap(1,depth,fun,tmpargs,args-1); stack_unlink(args); } /* Linked list stuff. */
-
#undef
INIT
_
BLOCK
-
#define
INIT
_
BLOCK(NODE)
do { \
-
(NODE)->next
=
(NODE)->prev = NULL; \
-
(NODE)->refs = 1; \
-
SET
_
SVAL
((
NODE)->val,
T
_
INT, NUMBER
_
UNDEFINED
,
\
-
integer, 0
);
\
-
} while(0)
+
static
struct block
_
allocator
pike
_
list_node_allocator
=
BA
_
INIT_PAGES
(
sizeof
(
struct
pike
_
list
_
node)
,
4
);
-
#undef EXIT_BLOCK
-
#define EXIT_BLOCK
(
NODE
)
do { \
-
if
(
(NODE
)
->prev)
{
\
-
free
_list_node
((NODE
)
->prev)
;
\
-
} \
-
if ((NODE)
->next
)
{
\
-
free_list_
node
((NODE)
->
next);
\
-
} \
-
free
_
svalue
(
&(NODE)
->val
);
\
-
}
while(0)
+
ATTRIBUTE
(
(malloc
)
)
+
static
struct
pike_list_node
*
alloc_pike_list_node
() {
+
struct
pike_list_node
*
node
=
ba
_
alloc(&pike_
list_node
_allocator
);
+
node
->next
=
node->prev
=
NULL;
+
node->
refs
=
1;
+
SET
_
SVAL
(
node
->val
,
T_INT,
NUMBER_UNDEFINED,
integer,
0);
+
return
node;
+
}
-
BLOCK
_
ALLOC
_
FILL
_
PAGES
(pike_list_node,
4
);
+
void count
_
memory
_
in
_
pike_list_nodes
(
size_t * n, size_t * s) {
+
ba_count_all(&
pike_list_node
_allocator
,
n, s
);
+
}
-
+
void free_all_pike_list_node_blocks() {
+
ba_destroy(&pike_list_node_allocator);
+
}
+
PMOD_EXPORT void free_list_node(struct pike_list_node *node) { if (!sub_ref(node)) {
-
really_
free_
pike_
list_node(node);
+
if (node->prev) {
+
free_list_node(node
->prev
);
}
-
+
if (node->next) {
+
free_list_node(node->next);
}
-
+
free_svalue(&node->val);
+
ba_free(&pike_list_node_allocator, node);
+
}
+
}
PMOD_EXPORT void unlink_list_node(struct pike_list_node *n) { #ifdef PIKE_DEBUG if (!n) { Pike_fatal("Unlinking NULL node.\n"); } if (!n->next || !n->prev) { Pike_fatal("Unlinking unlinked node.\n"); }
pike.git/src/builtin.cmod:5753:
PIKECLASS __Backtrace_Tester__ { INIT { Pike_error("__Backtrace_Tester__\n"); } } void init_builtin(void) {
-
init_pike_list_node_blocks();
+
INIT } void exit_builtin(void) { if (val_module) free_object (val_module); EXIT #ifndef DO_PIKE_CLEANUP /* This is performed by exit_builtin_modules() at a later point * in this case, so that the pike_list_node's are valid at cleanup * time, thus avoiding "got invalid pointer" fatals at exit. */
-
free
_
all_
pike_list_node_
blocks(
);
+
ba
_
destroy(&
pike_list_node_
allocator
);
#endif #ifndef USE_SETENV if (env_allocs) free_mapping (env_allocs); #endif }