source: git/omalloc/omAllocEmulate.c @ 599326

spielwiese
Last change on this file since 599326 was 599326, checked in by Kai Krüger <krueger@…>, 14 years ago
Anne, Kai, Frank: - changes to #include "..." statements to allow cleaner build structure - affected directories: omalloc, kernel, Singular - not yet done: IntergerProgramming git-svn-id: file:///usr/local/Singular/svn/trunk@13032 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$
7 *******************************************************************/
8#include <stdlib.h>
9#include <string.h>
10
11#include <omalloc/omMalloc.h>
12
13void* omEmulateAlloc0(size_t size)
14{
15  void* addr = OM_MALLOC_MALLOC(size);
16  memset(addr, 0, size);
17  return addr;
18}
19
20void* omEmulateRealloc0Size(void* o_addr, size_t o_size, size_t n_size)
21{
22  void* addr = OM_MALLOC_REALLOC(o_addr, n_size);
23
24  if (n_size > o_size)
25    memset((char *)addr + o_size, 0, n_size - o_size);
26
27  return addr;
28}
29
30void* omEmulateRealloc0(void* o_addr, size_t n_size)
31{
32#ifdef OM_MALLOC_SIZEOF_ADDR
33  size_t o_size = OM_MALLOC_SIZEOF_ADDR(o_addr);
34#endif
35  void* addr = OM_MALLOC_REALLOC(o_addr, n_size);
36#ifdef OM_MALLOC_SIZEOF_ADDR
37  if (n_size > o_size)
38    memset((char *)addr + o_size, 0, n_size - o_size);
39#endif
40  return addr;
41}
42
43#if defined(OM_EMULATE_OMALLOC) && defined(OM_PROVIDE_MALLOC)
44
45#undef calloc
46#undef malloc
47#undef realloc
48#undef free
49
50void* calloc(size_t n, size_t s)
51{
52  return omEmulateAlloc0(n*s);
53}
54
55void* malloc(size_t size)
56{
57  return OM_MALLOC_MALLOC(size);
58}
59
60void* realloc(void* o_addr, size_t n_size);
61{
62  return OM_MALLOC_REALLOC(size);
63}
64
65void free(void* addr)
66{
67  OM_MALLOC_FREE(addr);
68}
69
70#endif /* defined(OM_EMULATE_OMALLOC) && defined(OM_PROVIDE_MALLOC) */
Note: See TracBrowser for help on using the repository browser.