source: git/Singular/mmstd.c @ 1d3be3

fieker-DuValspielwiese
Last change on this file since 1d3be3 was 0c7a63, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
FIX: omConfig.h does NOT belong to the public interface of omalloc
  • Property mode set to 100644
File size: 1.4 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id$ */
5/*
6* ABSTRACT: standard version of C-memory management alloc func
7* i.e. (malloc/realloc/free)
8*/
9
10#include <kernel/mod2.h>
11
12#include <omalloc/omalloc.h>
13
14#include "static.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 <stdlib.h>
35void freeSize(void* addr, size_t size)
36{
37  if (addr) free(addr);
38}
39
40void* reallocSize(void* old_addr, size_t old_size, size_t new_size)
41{
42  if (old_addr && new_size)
43  {
44   return realloc(old_addr, new_size);
45  }
46  else 
47  {
48    freeSize(old_addr, old_size);
49    return malloc(new_size);
50  }
51}
52
53#endif
54
Note: See TracBrowser for help on using the repository browser.