source: git/omalloc/omAllocEmulate.c @ 08a955

fieker-DuValspielwiese
Last change on this file since 08a955 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
RevLine 
[e70e45]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>
[ce4f35]8#include <string.h>
[e70e45]9
[599326]10#include <omalloc/omMalloc.h>
[e70e45]11
[e12d106]12#ifdef OM_EMULATE_OMALLOC
13
[e70e45]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);
[13fe1b]24
[e70e45]25  if (n_size > o_size)
[13fe1b]26    memset((char *)addr + o_size, 0, n_size - o_size);
[e70e45]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);
[13fe1b]35#endif
[e70e45]36  void* addr = OM_MALLOC_REALLOC(o_addr, n_size);
[13fe1b]37#ifdef OM_MALLOC_SIZEOF_ADDR
[e70e45]38  if (n_size > o_size)
[13fe1b]39    memset((char *)addr + o_size, 0, n_size - o_size);
[e70e45]40#endif
41  return addr;
42}
[e12d106]43#endif
Note: See TracBrowser for help on using the repository browser.