My Project  debian-1:4.1.1-p2+ds-4build2
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 
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 
36 void freeSize(void* addr, size_t size)
37 {
38  (void) size;
39  if (addr) free(addr);
40 }
41 
42 void* 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 
omalloc.h
mmalloc.h
freeSize
#define freeSize
Definition: omAllocFunc.c:13
malloc
void * malloc(size_t size)
Definition: omalloc.c:92
mod2.h
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
free
#define free
Definition: omAllocFunc.c:12
realloc
#define realloc
Definition: omAllocFunc.c:14
reallocSize
#define reallocSize
Definition: omAllocFunc.c:15
omalloc.c