source: git/Singular/mmstd.c @ 894057

spielwiese
Last change on this file since 894057 was 715936, checked in by Oleksandr Motsak <motsak@…>, 13 years ago
FIX: omalloc should be configured with with-external-config_h=../Singular/omSingularConfig.h (?) FIX: moved memory management to Singular/ FIX: mmstd.c should not provide mm/c/v -alloc & free (recursion problem!)
  • 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 <omalloc/config.h>
14#include <omalloc/omConfig.h>
15
16#include "static.h"
17
18// we provide these functions, so that the settings of OM_CHECK
19// and OM_TRACK are used, but only provide them if omalloc is not based
20// on them
21// already provided in libomalloc
22#if !defined(OMALLOC_USES_MALLOC) && !defined(X_OMALLOC)
23
24/* in mmstd.c, for some architectures freeSize() unconditionally uses the *system* free() */
25/* sage ticket 5344: http://trac.sagemath.org/sage_trac/ticket/5344 */
26/* solution: correctly check OMALLOC_USES_MALLOC from omalloc.h, */
27/* do not rely on the default in Singular as libsingular may be different */
28
29// define this so that all addr allocated there are marked
30// as static, i.e. not metioned by omPrintUsedAddr
31#define OM_MALLOC_MARK_AS_STATIC
32#define strdup_ strdup__
33#include <omalloc/omalloc.c> /// UGLY!!!!!!!!!!!!!!!!
34
35#else
36#include <stdlib.h>
37void freeSize(void* addr, size_t size)
38{
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.