[a18f0a]: src / runtime / util.h Maximize Restore History

Download this file

util.h    41 lines (38 with data), 1.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* miscellaneous utilities
*/
/*
* This software is part of the SBCL system. See the README file for
* more information.
*
* This software is derived from the CMU CL system, which was
* written at Carnegie Mellon University and released into the
* public domain. The software is in the public domain and is
* provided with absolutely no warranty. See the COPYING and CREDITS
* files for more information.
*/
/*
* a utility to accumulate a zero-terminated array of void* values
*
* (Ah, lovely C, makes it such a delight to accumulate a collection
* whose length isn't known in advance.. but it's probably more fun
* than trying to teach the SBCL debugger to walk g++ stack frames, not to
* mention dealing with g++'s lovely in-which-file-do-templates-expand
* issues; or than trying to use Lisp for all accumulation and having to
* hassle about FFIing all the details of opendir/readdir/closedir
* and so forth.)
*
* We more or less simulate C++-style ctors and dtors.
*/
typedef struct
voidacc { /* the accumulator itself, to be treated as an opaque data type */
/*private:*/
void **result;
int n_avail;
int n_used;
} voidacc;
int voidacc_ctor(voidacc*); /* the ctor, returning 0 for success */
int voidacc_acc(voidacc*, void*); /* Accumulate an element into result,
* returning 0 for success. */
void** voidacc_give_away_result(voidacc*); /* giving away ownership */
void voidacc_dtor(voidacc*); /* the dtor */