source: git/omalloc/omAllocEmulate.c @ d011a2

spielwiese
Last change on this file since d011a2 was 13fe1b, checked in by Hans Schönemann <hannes@…>, 23 years ago
*hannes: DecAlpha-ccc-port git-svn-id: file:///usr/local/Singular/svn/trunk@5409 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*******************************************************************
2 *  File:    omAllocEmulate.c
3 *  Purpose: implementation of emulated omalloc routines
4 *  Author:  obachman (Olaf Bachmann)
5 *  Created: 11/99
6 *  Version: $Id: omAllocEmulate.c,v 1.4 2001-04-30 09:02:00 Singular Exp $
7 *******************************************************************/
8#include <stdlib.h>
9
10#include "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}
41
42#if defined(OM_EMULATE_OMALLOC) && defined(OM_PROVIDE_MALLOC)
43
44#undef calloc
45#undef malloc
46#undef realloc
47#undef free
48
49void* calloc(size_t n, size_t s)
50{
51  return omEmulateAlloc0(n*s);
52}
53
54void* malloc(size_t size)
55{
56  return OM_MALLOC_MALLOC(size);
57}
58
59void* realloc(void* o_addr, size_t n_size);
60{
61  return OM_MALLOC_REALLOC(size);
62}
63
64void free(void* addr)
65{
66  OM_MALLOC_FREE(addr);
67}
68
69#endif /* defined(OM_EMULATE_OMALLOC) && defined(OM_PROVIDE_MALLOC) */
Note: See TracBrowser for help on using the repository browser.