spielwiese
Last change
on this file since ab8937 was
a830133,
checked in by Hans Schönemann <hannes@…>, 15 years ago
|
*hannes: OMALLOC_USES_MALLOC
git-svn-id: file:///usr/local/Singular/svn/trunk@11565 2c84dea3-7e68-4137-9b89-c4e89433aadc
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[35aab3] | 1 | /**************************************** |
---|
| 2 | * Computer Algebra System SINGULAR * |
---|
| 3 | ****************************************/ |
---|
[a830133] | 4 | /* $Id: mminit.cc,v 1.2 2009-03-17 09:01:46 Singular Exp $ */ |
---|
[35aab3] | 5 | /* |
---|
| 6 | * ABSTRACT: init of memory management |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #include <stdio.h> |
---|
| 10 | #include <stdlib.h> |
---|
| 11 | |
---|
| 12 | #include "mod2.h" |
---|
| 13 | #include "mmalloc.h" |
---|
| 14 | #include "structs.h" |
---|
| 15 | // this prevents the definition of malloc/free and macros |
---|
| 16 | // by omalloc |
---|
| 17 | #define OMALLOC_C |
---|
| 18 | #include "omalloc.h" |
---|
| 19 | |
---|
| 20 | #include <si_gmp.h> |
---|
| 21 | |
---|
| 22 | int mmIsInitialized=mmInit(); |
---|
| 23 | |
---|
| 24 | extern "C" |
---|
| 25 | { |
---|
| 26 | void omSingOutOfMemoryFunc() |
---|
| 27 | { |
---|
| 28 | fprintf(stderr, "\nerror: no more memory\n"); |
---|
| 29 | omPrintStats(stderr); |
---|
| 30 | m2_end(14); |
---|
| 31 | /* should never get here */ |
---|
| 32 | exit(1); |
---|
| 33 | } |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | int mmInit( void ) |
---|
| 37 | { |
---|
| 38 | if(mmIsInitialized==0) |
---|
| 39 | { |
---|
| 40 | #if defined(OMALLOC_USES_MALLOC) || defined(X_OMALLOC) |
---|
[a830133] | 41 | /* in mmstd.c, for some architectures freeSize() unconditionally uses the *system* free() */ |
---|
| 42 | /* sage ticket 5344: http://trac.sagemath.org/sage_trac/ticket/5344 */ |
---|
| 43 | /* solution: correctly check OMALLOC_USES_MALLOC from omalloc.h, */ |
---|
| 44 | /* do not rely on the default in Singular as libsingular may be different */ |
---|
[35aab3] | 45 | mp_set_memory_functions(omMallocFunc,omReallocSizeFunc,omFreeSizeFunc); |
---|
| 46 | #else |
---|
| 47 | mp_set_memory_functions(malloc,reallocSize,freeSize); |
---|
| 48 | #endif |
---|
| 49 | om_Opts.OutOfMemoryFunc = omSingOutOfMemoryFunc; |
---|
| 50 | #ifndef OM_NDEBUG |
---|
| 51 | om_Opts.ErrorHook = dErrorBreak; |
---|
| 52 | #endif |
---|
| 53 | omInitInfo(); |
---|
| 54 | #ifdef OM_SING_KEEP |
---|
| 55 | om_Opts.Keep = OM_SING_KEEP; |
---|
| 56 | #endif |
---|
| 57 | } |
---|
| 58 | mmIsInitialized=1; |
---|
| 59 | return 1; |
---|
| 60 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.