source: git/omalloc/omAllocEmulate.c @ 7d6820

fieker-DuValspielwiese
Last change on this file since 7d6820 was e51781, checked in by Hans Schoenemann <hannes@…>, 7 years ago
omalloc: malloc_usable_sie, malloc_size
  • Property mode set to 100644
File size: 971 bytes
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 "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  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
Note: See TracBrowser for help on using the repository browser.