source: git/kernel/mmstd.c @ f2f460

spielwiese
Last change on this file since f2f460 was 55b5cfd, checked in by Michael Brickenstein <bricken@…>, 18 years ago
*bricken: ix86Mac git-svn-id: file:///usr/local/Singular/svn/trunk@9310 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.2 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: mmstd.c,v 1.3 2006-07-18 11:25:05 bricken Exp $ */
5/*
6* ABSTRACT: standard version of C-memory management alloc func
7* i.e. (malloc/realloc/free)
8*/
9
10#include "mod2.h"
11
12#define OM_NO_MALLOC_MACROS
13#ifdef ix86_Win
14#define OMALLOC_USES_MALLOC
15#endif
16#ifdef ppcMac_darwin
17#define OMALLOC_USES_MALLOC
18#endif
19#ifdef ix86Mac_darwin
20#define OMALLOC_USES_MALLOC
21#endif
22#include "omalloc.h"
23
24// we provide these functions, so that the settings of OM_CHECK
25// and OM_TRACK are used, but only provide them if omalloc is not based
26// on them
27// already provided in libomalloc
28#if !defined(OMALLOC_USES_MALLOC) && !defined(X_OMALLOC)
29
30// define this so that all addr allocated there are marked
31// as static, i.e. not metioned by omPrintUsedAddr
32#define OM_MALLOC_MARK_AS_STATIC
33#define strdup_ strdup__
34#include <omalloc.c>
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#endif
55
Note: See TracBrowser for help on using the repository browser.