source: git/kernel/mmstd.c @ 1d9b39

spielwiese
Last change on this file since 1d9b39 was aed2cd2, checked in by Hans Schoenemann <hannes@…>, 13 years ago
removed OM_NO_MALLOC_MACROS git-svn-id: file:///usr/local/Singular/svn/trunk@14107 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • 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#include <Singular/static.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    /* in mmstd.c, for some architectures freeSize() unconditionally uses the *system* free() */
21    /* sage ticket 5344: http://trac.sagemath.org/sage_trac/ticket/5344 */
22    /* solution: correctly check OMALLOC_USES_MALLOC from omalloc.h, */
23    /* do not rely on the default in Singular as libsingular may be different */
24
25// define this so that all addr allocated there are marked
26// as static, i.e. not metioned by omPrintUsedAddr
27#define OM_MALLOC_MARK_AS_STATIC
28#define strdup_ strdup__
29#include <omalloc/omalloc.c>
30#else
31#include <stdlib.h>
32void freeSize(void* addr, size_t size)
33{
34  if (addr) free(addr);
35}
36
37void* reallocSize(void* old_addr, size_t old_size, size_t new_size)
38{
39  if (old_addr && new_size)
40  {
41   return realloc(old_addr, new_size);
42  }
43  else 
44  {
45    freeSize(old_addr, old_size);
46    return malloc(new_size);
47  }
48}
49
50#endif
51
Note: See TracBrowser for help on using the repository browser.