core: make_struct: Avoid creating garbage.

* src/struct.c (make_struct): Use STRUCT TYPE PRINTER FIELD0 ... FIELDN.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2020-08-16 17:03:31 +02:00
parent b30af2ce9f
commit c247733bcd
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273

View file

@ -25,8 +25,11 @@ SCM
make_struct (SCM type, SCM fields, SCM printer)
{
long size = 2 + length__ (fields);
SCM x = alloc (1);
SCM v = alloc (size);
SCM x = make_cell (TSTRUCT, size, v);
TYPE (x) = TSTRUCT;
LENGTH (x) = size;
STRUCT (x) = v;
copy_cell (v, vector_entry (type));
copy_cell (cell_ref (v, 1), vector_entry (printer));
long i;