source: git/Singular/mmstd.c @ a4b31c

spielwiese
Last change on this file since a4b31c was a4b31c, checked in by Hans Schoenemann <hannes@…>, 7 years ago
use include ".." for singular related .h, p4
  • Property mode set to 100644
File size: 1.4 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/*
5* ABSTRACT: standard version of C-memory management alloc func
6* i.e. (malloc/realloc/free)
7*/
8
9
10
11
12#include "kernel/mod2.h"
13
14#include "omalloc/omalloc.h"
15
16/* we provide these functions, so that the settings of OM_CHECK
17* and OM_TRACK are used, but only provide them if omalloc is not based
18* on them
19* already provided in libomalloc */
20#if !defined(OMALLOC_USES_MALLOC) && !defined(X_OMALLOC)
21
22/* in mmstd.c, for some architectures freeSize() unconditionally uses the *system* free() */
23/* sage ticket 5344: http://trac.sagemath.org/sage_trac/ticket/5344 */
24/* solution: correctly check OMALLOC_USES_MALLOC from omalloc.h, */
25/* do not rely on the default in Singular as libsingular may be different */
26
27/* define this so that all addr allocated there are marked
28* as static, i.e. not metioned by omPrintUsedAddr*/
29#define OM_MALLOC_MARK_AS_STATIC
30#define strdup_ strdup__
31#include "omalloc/omalloc.c" /// UGLY!!!!!!!!!!!!!!!!
32
33#else
34#include "Singular/mmalloc.h"
35
36void freeSize(void* addr, size_t size)
37{
38  (void) size;
39  if (addr) free(addr);
40}
41
42void* reallocSize(void* old_addr, size_t old_size, size_t new_size)
43{
44  if (old_addr && new_size)
45  {
46   return realloc(old_addr, new_size);
47  }
48  else
49  {
50    freeSize(old_addr, old_size);
51    return malloc(new_size);
52  }
53}
54
55#endif
56
Note: See TracBrowser for help on using the repository browser.