9 #include <grass/linkm.h>
12 struct link_head *
link_new(
struct link_head *Head)
18 if (Head->Unused ==
NULL) {
19 if (Head->max_ptr >= Head->alloced) {
23 (
VOID_T *) realloc(Head->ptr_array,
24 sizeof(
VOID_T *) * Head->alloced * 2))) {
29 Head->ptr_array = (
VOID_T **) tmp;
35 malloc(Head->chunk_size * Head->unit_size))) {
38 return (
struct link_head *)
NULL;
41 Head->ptr_array[Head->max_ptr++] = (
VOID_T *) tmp;
42 Head->Unused = (
VOID_T *) tmp;
44 p = ctmp = (
char *)tmp;
45 for (i = 0; i < Head->chunk_size - 1; i++) {
47 (
VOID_T *) & (ctmp[(i + 1) * Head->unit_size]));
50 p = &(ctmp[(i + 1) * Head->unit_size]);
60 return (
struct link_head *)tmp;
struct link_head * link_new(struct link_head *Head)
int link_out_of_memory(void)
void link__set_next(VOID_T *a, VOID_T *b)
VOID_T * link__get_next(VOID_T *list)