source: git/Singular/mminit.cc @ 28e0ac8

fieker-DuValspielwiese
Last change on this file since 28e0ac8 was 50cbdc, checked in by Hans Schönemann <hannes@…>, 23 years ago
*hannes: merge-2-0-2 git-svn-id: file:///usr/local/Singular/svn/trunk@5619 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.2 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: mminit.cc,v 1.24 2001-08-27 14:47:11 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
20extern "C"
21{
22#include <gmp.h>
23}
24
25int mmIsInitialized=mmInit();
26
27extern "C"
28{
29  void omSingOutOfMemoryFunc()
30  {
31    fprintf(stderr, "\nerror: no more memory\n");
32    omPrintStats(stderr);
33    m2_end(14);
34    /* should never get here */
35    exit(1);
36  }
37}
38
39int mmInit( void )
40{
41  if(mmIsInitialized==0)
42  {
43#if defined(OMALLOC_USES_MALLOC) || defined(X_OMALLOC)
44    mp_set_memory_functions(omMallocFunc,omReallocSizeFunc,omFreeSizeFunc);
45#else
46    mp_set_memory_functions(malloc,reallocSize,freeSize);
47#endif
48    om_Opts.OutOfMemoryFunc = omSingOutOfMemoryFunc;
49#ifndef OM_NDEBUG
50    om_Opts.ErrorHook = dErrorBreak;
51#endif
52    omInitInfo();
53#ifdef OM_SING_KEEP
54    om_Opts.Keep = OM_SING_KEEP;
55#endif
56  }
57  mmIsInitialized=1;
58  return 1;
59}
Note: See TracBrowser for help on using the repository browser.