source: git/kernel/mminit.cc @ 5f6d137

spielwiese
Last change on this file since 5f6d137 was 5f6d137, checked in by Hans Schönemann <hannes@…>, 15 years ago
*hannes: static binaries and malloc git-svn-id: file:///usr/local/Singular/svn/trunk@11578 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.5 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: mminit.cc,v 1.4 2009-03-19 10:34:00 Singular Exp $ */
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
22int mmIsInitialized=mmInit();
23
24extern "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
36int mmInit( void )
37{
38  if(mmIsInitialized==0)
39  {
40#if defined(OMALLOC_USES_MALLOC) || defined(X_OMALLOC)
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 */
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.