My Project  UNKNOWN_GIT_VERSION
omAllocEmulate.c
Go to the documentation of this file.
1 /*******************************************************************
2  * File: omAllocEmulate.c
3  * Purpose: implementation of emulated omalloc routines
4  * Author: obachman (Olaf Bachmann)
5  * Created: 11/99
6  *******************************************************************/
7 #include <stdlib.h>
8 #include <string.h>
9 
10 #include "omMalloc.h"
11 
12 #ifdef OM_EMULATE_OMALLOC
13 
14 void* omEmulateAlloc0(size_t size)
15 {
16  void* addr = OM_MALLOC_MALLOC(size);
17  memset(addr, 0, size);
18  return addr;
19 }
20 
21 void* omEmulateRealloc0Size(void* o_addr, size_t o_size, size_t n_size)
22 {
23  void* addr = OM_MALLOC_REALLOC(o_addr, n_size);
24 
25  if (n_size > o_size)
26  memset((char *)addr + o_size, 0, n_size - o_size);
27 
28  return addr;
29 }
30 
31 void* omEmulateRealloc0(void* o_addr, size_t n_size)
32 {
33  size_t o_size = OM_MALLOC_SIZEOF_ADDR(o_addr);
34  void* addr = OM_MALLOC_REALLOC(o_addr, n_size);
35  if (n_size > o_size)
36  memset((char *)addr + o_size, 0, n_size - o_size);
37  return addr;
38 }
39 #endif
OM_MALLOC_SIZEOF_ADDR
static size_t OM_MALLOC_SIZEOF_ADDR(void *d)
Definition: omMallocSystem.h:24
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
OM_MALLOC_MALLOC
#define OM_MALLOC_MALLOC
Definition: omMallocSystem.h:10
OM_MALLOC_REALLOC
#define OM_MALLOC_REALLOC
Definition: omMallocSystem.h:11
omMalloc.h