source: git/omalloc/omAllocEmulate.c @ 5e28ea

spielwiese
Last change on this file since 5e28ea was 6ce030f, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
removal of the $Id$ svn tag from everywhere NOTE: the git SHA1 may be used instead (only on special places) NOTE: the libraries Singular/LIB/*.lib still contain the marker due to our current use of svn
  • Property mode set to 100644
File size: 1017 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 <omalloc/omMalloc.h>
11
12void* omEmulateAlloc0(size_t size)
13{
14  void* addr = OM_MALLOC_MALLOC(size);
15  memset(addr, 0, size);
16  return addr;
17}
18
19void* omEmulateRealloc0Size(void* o_addr, size_t o_size, size_t n_size)
20{
21  void* addr = OM_MALLOC_REALLOC(o_addr, n_size);
22
23  if (n_size > o_size)
24    memset((char *)addr + o_size, 0, n_size - o_size);
25
26  return addr;
27}
28
29void* omEmulateRealloc0(void* o_addr, size_t n_size)
30{
31#ifdef OM_MALLOC_SIZEOF_ADDR
32  size_t o_size = OM_MALLOC_SIZEOF_ADDR(o_addr);
33#endif
34  void* addr = OM_MALLOC_REALLOC(o_addr, n_size);
35#ifdef OM_MALLOC_SIZEOF_ADDR
36  if (n_size > o_size)
37    memset((char *)addr + o_size, 0, n_size - o_size);
38#endif
39  return addr;
40}
Note: See TracBrowser for help on using the repository browser.