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 #ifdef OM_MALLOC_SIZEOF_ADDR
34  size_t o_size = OM_MALLOC_SIZEOF_ADDR(o_addr);
35 #endif
36  void* addr = OM_MALLOC_REALLOC(o_addr, n_size);
37 #ifdef OM_MALLOC_SIZEOF_ADDR
38  if (n_size > o_size)
39  memset((char *)addr + o_size, 0, n_size - o_size);
40 #endif
41  return addr;
42 }
43 #endif
#define OM_MALLOC_MALLOC
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
#define OM_MALLOC_REALLOC
#define OM_MALLOC_SIZEOF_ADDR(addr)