/* -*-comment-start: "//";comment-end:""-*- * Mes --- Maxwell Equations of Software * Copyright © 2016 Jan Nieuwenhuizen * * This file is part of Mes. * * Mes is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or (at * your option) any later version. * * Mes is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Mes. If not, see . */ SCM gc_up_arena () ///((internal)) { #if _POSIX_SOURCE ARENA_SIZE *= 2; void *p = realloc (g_cells-1, 2*ARENA_SIZE*sizeof(struct scm)); #else ARENA_SIZE = ARENA_SIZE * 2; //p = realloc (g_cells-1, 2*ARENA_SIZE*sizeof(struct scm)); int size = ARENA_SIZE * 2; size = size * 12; char *p = size; p = realloc (g_cells-1, size); g_cells = p; #endif #if _POSIX_SOURCE if (!p) error (cell_symbol_system_error, cons (MAKE_STRING (cstring_to_list (strerror (errno))), MAKE_NUMBER (g_free))); g_cells = (struct scm*)p; g_cells++; #else //assert (p); //g_cells = (struct scm*)p; #endif gc_init_news (); return 0; } SCM gc_flip () ///((internal)) { struct scm *cells = g_cells; g_cells = g_news; g_news = cells; #if _POSIX_SOURCE if (g_debug) fprintf (stderr, ";;; => jam[%d]\n", g_free); #else if (g_debug) { eputs (";;; => jam["); eputs (itoa (g_free)); eputs ("]\n"); } #endif return g_stack; } SCM gc_copy (SCM old) ///((internal)) { if (TYPE (old) == TBROKEN_HEART) return g_cells[old].car; SCM new = g_free++; g_news[new] = g_cells[old]; if (NTYPE (new) == TVECTOR) { NVECTOR (new) = g_free; for (int i=0; i