source: git/omalloc/omAllocEmulate.c @ cadaf2

spielwiese
Last change on this file since cadaf2 was e12d106, checked in by Hans Schoenemann <hannes@…>, 11 years ago
fix: optional code im omalloc
  • Property mode set to 100644
File size: 1.0 KB
Line 
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 <omalloc/omMalloc.h>
11
12#ifdef OM_EMULATE_OMALLOC
13
14void* omEmulateAlloc0(size_t size)
15{
16  void* addr = OM_MALLOC_MALLOC(size);
17  memset(addr, 0, size);
18  return addr;
19}
20
21void* 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
31void* 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
Note: See TracBrowser for help on using the repository browser.