From af7510a67bcb8b621a3acacafc29ef5ccc1acaa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Thu, 12 Apr 2012 23:25:04 +0100 Subject: [PATCH] fix handling of repeated calls to YAP_Init. --- C/c_interface.c | 8 +++++++- include/yap_structs.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/C/c_interface.c b/C/c_interface.c index 2a4959744..1336906fe 100644 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -2937,7 +2937,13 @@ YAP_Init(YAP_init_args *yap_init) int restore_result; int do_bootstrap = (yap_init->YapPrologBootFile != NULL); CELL Trail = 0, Stack = 0, Heap = 0, Atts = 0; - static char boot_file[256]; + char boot_file[256]; + static int initialised = FALSE; + + /* ignore repeated calls to YAP_Init */ + if (initialised) + return YAP_BOOT_DONE_BEFOREHAND; + initialised = TRUE; Yap_InitPageSize(); /* init memory page size, required by later functions */ #if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA) diff --git a/include/yap_structs.h b/include/yap_structs.h index fd98977f1..f77e51b6e 100644 --- a/include/yap_structs.h +++ b/include/yap_structs.h @@ -115,6 +115,7 @@ typedef enum { #define YAP_BOOT_FROM_SAVED_CODE 1 #define YAP_BOOT_FROM_SAVED_STACKS 2 #define YAP_FULL_BOOT_FROM_PROLOG 4 +#define YAP_BOOT_DONE_BEFOREHAND 8 #define YAP_BOOT_ERROR -1 #define YAP_WRITE_QUOTED 1