source: git/omalloc/omAllocEmulate.c @ e70e45

spielwiese
Last change on this file since e70e45 was e70e45, checked in by Olaf Bachmann <obachman@…>, 24 years ago
* re-added files git-svn-id: file:///usr/local/Singular/svn/trunk@4521 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.3 2000-08-14 12:26:39 obachman 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(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(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.