blob: 48ce110af524326cf62e7a752cc98e47616f7824 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
// -*- C++ -*-
//=============================================================================
/**
* @file OS_Memory.h
*
* $Id$
*
* @author Doug Schmidt <schmidt@cs.wustl.edu>
* @author Jesper S. M|ller<stophph@diku.dk>
* @author and a cast of thousands...
*/
//=============================================================================
#ifndef ACE_OS_MEMORY_H
#define ACE_OS_MEMORY_H
#include "ace/pre.h"
#include "ace/config-all.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/OS_Export.h"
#if defined (ACE_HAS_PACE)
# include /**/ "pace/stdlib.h"
#endif /* ACE_HAS_PACE */
#include /**/ <stddef.h>
# if !defined (ACE_MALLOC_ALIGN)
# define ACE_MALLOC_ALIGN ((int) sizeof (long))
# endif /* ACE_MALLOC_ALIGN */
# if !defined (ACE_HAS_POSITION_INDEPENDENT_POINTERS)
# define ACE_HAS_POSITION_INDEPENDENT_POINTERS 1
# endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS */
// Allow an installation to replace the lowest-level allocation
// functions without changing the source of ACE.
//
// To do this, simple #define ACE_*_FUNC macros in config.h to
// the names of the site-specific functions, e.g.,
//
// #define ACE_MALLOC_FUNC dlmalloc
// #define ACE_CALLOC_FUNC dlcalloc
// #define ACE_FREE_FUNC dlfree
// #define ACE_REALLOC_FUNC dlrealloc
//
// For completeness' sake, you should probably put
// #define ACE_HAS_STRDUP_EMULATION
// too, so that you guarantee that strdup() calls your desired mallocator
// and not the system mallocator.
//
# if defined (ACE_HAS_PACE)
# if !defined (ACE_MALLOC_FUNC)
# define ACE_MALLOC_FUNC pace_malloc
# endif
# if !defined (ACE_CALLOC_FUNC)
# define ACE_CALLOC_FUNC pace_calloc
# endif
# if !defined (ACE_FREE_FUNC)
# define ACE_FREE_FUNC pace_free
# endif
# if !defined (ACE_REALLOC_FUNC)
# define ACE_REALLOC_FUNC pace_realloc
# endif
# if defined (ACE_HAS_OLD_MALLOC)
typedef char *ACE_MALLOC_T;
# else
typedef void *ACE_MALLOC_T;
# endif /* ACE_HAS_OLD_MALLOC */
# else
# if !defined (ACE_MALLOC_FUNC)
# define ACE_MALLOC_FUNC ::malloc
# endif
# if !defined (ACE_CALLOC_FUNC)
# define ACE_CALLOC_FUNC ::calloc
# endif
# if !defined (ACE_FREE_FUNC)
# define ACE_FREE_FUNC ::free
# endif
# if !defined (ACE_REALLOC_FUNC)
# define ACE_REALLOC_FUNC ::realloc
# endif
# if defined (ACE_HAS_OLD_MALLOC)
typedef char *ACE_MALLOC_T;
# else
typedef void *ACE_MALLOC_T;
# endif /* ACE_HAS_OLD_MALLOC */
#endif /* ACE_HAS_PACE */
/**
* @class ACE_OS_Memory
*
* @brief This class is a wrapper for dynamic memory operations.
*
*/
class ACE_OS_Export ACE_OS_Memory
{
public:
// = A set of wrappers for memory managment.
static void *sbrk (int brk);
static void *calloc (size_t elements, size_t sizeof_elements);
static void *malloc (size_t);
static void *realloc (void *, size_t);
static void free (void *);
};
# if defined (ACE_HAS_INLINED_OSCALLS)
# if defined (ACE_INLINE)
# undef ACE_INLINE
# endif /* ACE_INLINE */
# define ACE_INLINE inline
# include "ace/OS_Memory.inl"
# endif /* ACE_HAS_INLINED_OSCALLS */
#include "ace/post.h"
#endif /* ACE_OS_MEMORY_H */
|