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
1 changed files with 4 additions and 1 deletions

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;