source: git/Singular/mmstd.c @ 17228e

spielwiese
Last change on this file since 17228e was 17228e, checked in by Hans Schoenemann <hannes@…>, 12 years ago
fix: make check (for non-dbug version) removed: static.h
  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[35aab3]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
[762407]9#include "config.h"
[599326]10#include <kernel/mod2.h>
[35aab3]11
[b1dfaf]12#include <omalloc/omalloc.h>
[715936]13
[35aab3]14// we provide these functions, so that the settings of OM_CHECK
15// and OM_TRACK are used, but only provide them if omalloc is not based
16// on them
[30b8381]17// already provided in libomalloc
[b54aa2d]18#if !defined(OMALLOC_USES_MALLOC) && !defined(X_OMALLOC)
[715936]19
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 */
[35aab3]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
[30b8381]28#define strdup_ strdup__
[715936]29#include <omalloc/omalloc.c> /// UGLY!!!!!!!!!!!!!!!!
30
[35aab3]31#else
[bd795d]32#include <Singular/mmalloc.h>
33
[35aab3]34void freeSize(void* addr, size_t size)
35{
36  if (addr) free(addr);
37}
38
39void* reallocSize(void* old_addr, size_t old_size, size_t new_size)
40{
41  if (old_addr && new_size)
42  {
43   return realloc(old_addr, new_size);
44  }
45  else 
46  {
47    freeSize(old_addr, old_size);
48    return malloc(new_size);
49  }
50}
[b54aa2d]51
52#endif
[35aab3]53
Note: See TracBrowser for help on using the repository browser.