source: git/Singular/mmstd.c @ d7ad81

spielwiese
Last change on this file since d7ad81 was 6ce030f, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
removal of the $Id$ svn tag from everywhere NOTE: the git SHA1 may be used instead (only on special places) NOTE: the libraries Singular/LIB/*.lib still contain the marker due to our current use of svn
  • Property mode set to 100644
File size: 1.4 KB
Line 
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#include "config.h"
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 <Singular/mmalloc.h>
35
36void freeSize(void* addr, size_t size)
37{
38  if (addr) free(addr);
39}
40
41void* 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
Note: See TracBrowser for help on using the repository browser.