My Project
mmstd.c
Go to the documentation of this file.
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 #include "omalloc/omalloc.h"
14 
15 /* we provide these functions, so that the settings of OM_CHECK
16 * and OM_TRACK are used, but only provide them if omalloc is not based
17 * on them
18 * already provided in libomalloc */
19 #if !defined(OMALLOC_USES_MALLOC) && !defined(X_OMALLOC)
20 
21 /* in mmstd.c, for some architectures freeSize() unconditionally uses the *system* free() */
22 /* sage ticket 5344: http://trac.sagemath.org/sage_trac/ticket/5344 */
23 /* solution: correctly check OMALLOC_USES_MALLOC from omalloc.h, */
24 /* do not rely on the default in Singular as libsingular may be different */
25 
26 /* define this so that all addr allocated there are marked
27 * as static, i.e. not metioned by omPrintUsedAddr*/
28 #define OM_MALLOC_MARK_AS_STATIC
29 #define strdup_ strdup__
30 #include "omalloc/omalloc.c" /// UGLY!!!!!!!!!!!!!!!!
31 
32 #else
33 #include "Singular/mmalloc.h"
34 
35 void freeSize(void* addr, size_t size)
36 {
37  (void) size;
38  if (addr) free(addr);
39 }
40 
41 void* reallocSize(void* old_addr, size_t old_size, size_t new_size)
42 {
43  if (old_addr && new_size)
44  {
45  return realloc(old_addr, new_size);
46  }
47  else
48  {
49  freeSize(old_addr, old_size);
50  return malloc(new_size);
51  }
52 }
53 
54 #endif
55 
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
#define realloc
Definition: omAllocFunc.c:16
#define freeSize
Definition: omAllocFunc.c:15
#define free
Definition: omAllocFunc.c:14
#define reallocSize
Definition: omAllocFunc.c:17
void * malloc(size_t size)
Definition: omalloc.c:85