1 /* $Id: log.c,v 1.7 1994/06/24 11:17:51 ceriel Exp $ */
3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
11 /* Logical manipulations.
12 The chunks are properly chained in the physical chain.
15 privatedata mallink *free_list[MAX_FLIST];
21 /* The free chunk ml is inserted in its proper logical
24 register mallink **mlp = &free_list[-1];
25 register size_type n = size_of(ml);
26 register mallink *ml1;
28 assert(n < (1L << LOG_MAX_SIZE));
34 while (n >= MIN_SIZE);
37 set_log_prev(ml, MAL_NULL);
38 set_log_next(ml, ml1);
43 set_log_prev(ml1, ml);
53 /* Unlinks a free chunk from (the middle of) the
56 register mallink *next = log_next_of(ml);
57 register mallink *prev = log_prev_of(ml);
60 /* it is the first in the chain */
61 register mallink **mlp = &free_list[-1];
62 register size_type n = size_of(ml);
64 assert(n < (1L << LOG_MAX_SIZE));
69 while (n >= MIN_SIZE);
73 set_log_next(prev, next);
77 set_log_prev(next, prev);
83 search_free_list(class, n)
86 /* Searches the free_list[class] for a chunk of at least size n;
87 since it is searching a slightly undersized list,
88 such a block may not be there.
92 for (ml = free_list[class]; ml; ml = log_next_of(ml))
95 return MAL_NULL; /* nothing found */
102 /* Find the index i in free_list[] such that:
103 i >= class && free_list[i] != MAL_NULL.
104 Return MAL_NULL if no such i exists;
105 Otherwise, return the first block of this list, after
108 register mallink **mlp, *ml;
110 for (mlp = &free_list[class]; mlp < &free_list[MAX_FLIST]; mlp++) {
111 if ((ml = *mlp) != MAL_NULL) {
113 *mlp = log_next_of(ml); /* may be MAL_NULL */
115 /* unhook backward link
117 set_log_prev(*mlp, MAL_NULL);
129 /* To allow maldump.c access to log.c's private data.