source: git/Singular/mminit.cc @ 592ae9

spielwiese
Last change on this file since 592ae9 was 592ae9, checked in by Hans Schönemann <hannes@…>, 24 years ago
*hannes: port to non-linux git-svn-id: file:///usr/local/Singular/svn/trunk@3837 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: mminit.cc,v 1.19 1999-11-17 13:35:34 hannes 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#if defined(MTRACK) && defined(linux) && defined(__i386__)
32  extern int mm_no_mtrack;
33  mm_no_mtrack = 1;
34#endif
35  void* addr;
36  addr = mmDBAlloc( size, "new",0);
37#if defined(MTRACK) && defined(linux) && defined(__i386__)
38  mm_no_mtrack = 0;
39#endif
40  return addr;
41#else
42  return AllocL( size );
43#endif
44}
45
46void operator delete ( void* block )
47{
48#ifdef MDEBUG
49  mmDBFree( block, "delete",0);
50#else
51  FreeL( block );
52#endif
53}
54
55#ifdef MDEBUG
56void * mgAllocBlock( size_t t)
57{
58  return mmDBAllocBlock(t,"gmp",0);
59}
60void mgFreeBlock( void* a, size_t t)
61{
62  mmDBFreeBlock(a,t,"gmp",0);
63}
64void * mgReallocBlock( void* a, size_t t1, size_t t2)
65{
66  return mmDBReallocBlock(a,t1,t2,"gmp",0);
67}
68#endif
69
70#ifdef HAVE_SBRK
71#include <unistd.h>
72unsigned long mm_SbrkInit = (unsigned long)sbrk(0);
73#endif
74
75static int mmIsInitialized=mmInit();
76
77int mmInit( void )
78{
79  if(mmIsInitialized==0)
80  {
81#ifndef MDEBUG
82    mp_set_memory_functions(mmAllocBlock,mmReallocBlock,mmFreeBlock);
83#else
84    mp_set_memory_functions(mgAllocBlock,mgReallocBlock,mgFreeBlock);
85#endif
86  }
87  mmIsInitialized=1;
88  return 1;
89}
Note: See TracBrowser for help on using the repository browser.