From 96d2ff96e080dfb5e31ce92cb0fb83339314b5df Mon Sep 17 00:00:00 2001 From: h_vogt Date: Fri, 3 Aug 2012 08:28:50 +0200 Subject: [PATCH] alloc.c: exlude controlled_exit if not MS Windows not available in some tests in cmaths and executable like ngproc2mod --- src/misc/alloc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/misc/alloc.c b/src/misc/alloc.c index 971d5554b..7c76dd995 100644 --- a/src/misc/alloc.c +++ b/src/misc/alloc.c @@ -7,6 +7,12 @@ Copyright 1990 Regents of the University of California. All rights reserved. */ #include "ngspice/ngspice.h" +/* We need this because some tests in cmaths and some executables other + than ngspice and ngnutmeg under LINUX don't know about controlled_exit */ +#ifdef HAS_WINDOWS +extern void controlled_exit(int status); +#endif + #ifndef HAVE_LIBGC /*saj For Tcl module locking*/ @@ -42,7 +48,11 @@ tmalloc(size_t num) #endif if (!s){ fprintf(stderr,"malloc: Internal Error: can't allocate %ld bytes. \n",(long)num); +#ifdef HAS_WINDOWS + controlled_exit(EXIT_FAILURE); +#else exit(EXIT_FAILURE); +#endif } return(s); } @@ -78,7 +88,11 @@ trealloc(void *ptr, size_t num) } if (!s) { fprintf(stderr,"realloc: Internal Error: can't allocate %ld bytes.\n", (long)num); - exit(EXIT_FAILURE); +#ifdef HAS_WINDOWS + controlled_exit(EXIT_FAILURE); +#else + exit(EXIT_FAILURE); +#endif } return(s); }