Cyclone Scheme  0.28.0

◆ alloc_string

#define alloc_string (   _data,
  _s,
  _len,
  _num_cp 
)
Value:
if (_len >= MAX_STACK_OBJ) { \
int heap_grown; \
_s = gc_alloc(((gc_thread_data *)data)->heap, \
sizeof(string_type) + _len + 1, \
boolean_f, /* OK to populate manually over here */ \
(gc_thread_data *)data, \
&heap_grown); \
((string_type *) _s)->hdr.mark = ((gc_thread_data *)data)->gc_alloc_color; \
((string_type *) _s)->hdr.grayed = 0; \
((string_type *) _s)->hdr.immutable = 0; \
((string_type *) _s)->tag = string_tag; \
((string_type *) _s)->len = _len; \
((string_type *) _s)->num_cp = _num_cp; \
((string_type *) _s)->str = (((char *)_s) + sizeof(string_type)); \
} else { \
_s = alloca(sizeof(string_type)); \
((string_type *)_s)->hdr.mark = gc_color_red; \
((string_type *)_s)->hdr.grayed = 0; \
((string_type *)_s)->hdr.immutable = 0; \
((string_type *)_s)->tag = string_tag; \
((string_type *)_s)->len = _len; \
((string_type *)_s)->num_cp = _num_cp; \
((string_type *)_s)->str = alloca(sizeof(char) * (_len + 1)); \
}

Allocate a new string, either on the stack or heap depending upon size

gc_alloc
void * gc_alloc(gc_heap_root *h, size_t size, char *obj, gc_thread_data *thd, int *heap_grown)
Allocate memory on the heap for an object.
Definition: gc.c:1360
gc_color_red
#define gc_color_red
Definition: types.h:297
gc_thread_data_t
Definition: types.h:322
string_type
The string type.
Definition: types.h:933
string_tag
@ string_tag
Definition: types.h:67
MAX_STACK_OBJ
#define MAX_STACK_OBJ
Definition: types.h:513
boolean_f
const object boolean_f
Definition: runtime.c:397