source: git/Singular/mminit.cc @ 9235af

spielwiese
Last change on this file since 9235af was 9235af, checked in by Hans Schönemann <hannes@…>, 25 years ago
* hannes: added mmInit to to mpr_complex: global class object need it git-svn-id: file:///usr/local/Singular/svn/trunk@3660 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.4 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: mminit.cc,v 1.16 1999-09-24 16:39:46 Singular Exp $ */
5/*
6* ABSTRACT: init of memory management
7*/
8
9#define _POSIX_SOURCE 1
10
11#include <stdlib.h>
12#include <string.h>
13#define __USE_MISC
14#include <unistd.h>
15#ifdef macintosh
16#include <types.h>
17#else
18#include <sys/types.h>
19#endif
20#include "mod2.h"
21#include "mmemory.h"
22#include "mmprivate.h"
23extern "C" { /* begin of "C" */
24#include <gmp.h>
25memHeap mm_specHeap = NULL;
26} /* end of "C" */
27
28void* operator new ( size_t size )
29{
30#ifdef MDEBUG
31  return mmDBAlloc( size, "new",0);
32#else
33  return AllocL( size );
34#endif
35}
36
37void operator delete ( void* block )
38{
39#ifdef MDEBUG
40  mmDBFree( block, "delete",0);
41#else
42  FreeL( block );
43#endif
44}
45
46#ifdef MDEBUG
47void * mgAllocBlock( size_t t)
48{
49  return mmDBAllocBlock(t,"gmp",0);
50}
51void mgFreeBlock( void* a, size_t t)
52{
53  mmDBFreeBlock(a,t,"gmp",0);
54}
55void * mgReallocBlock( void* a, size_t t1, size_t t2)
56{
57  return mmDBReallocBlock(a,t1,t2,"gmp",0);
58}
59#endif
60
61#ifdef HAVE_SBRK
62#include <unistd.h>
63unsigned long mm_SbrkInit = (unsigned long)sbrk(0);
64#endif
65
66static int mmIsInitialized=mmInit();
67
68int mmInit( void )
69{
70  if(mmIsInitialized==0)
71  {
72#ifndef MDEBUG
73    mp_set_memory_functions(mmAllocBlock,mmReallocBlock,mmFreeBlock);
74#else
75    mp_set_memory_functions(mgAllocBlock,mgReallocBlock,mgFreeBlock);
76#endif
77  }
78  mmIsInitialized=1;
79  return 1;
80}
Note: See TracBrowser for help on using the repository browser.