blob: d44ef43fa138caab058a5c435315317c85c154f6 (
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
|
/* -*- C++ -*- */
// $Id$
// ============================================================================
//
// = LIBRARY
// ace
//
// = FILENAME
// Obstack.h
//
// = AUTHOR
// Doug Schmidt
//
// ============================================================================
#if !defined (ACE_OBSTACK_H)
#define ACE_OBSTACK_H
#include "ace/ACE.h"
class ACE_Export ACE_Obchunk
{
// = TITLE
// A "chunk" of memory. This should be a nested class but some
// compilers don't like them yet.
friend class ACE_Obstack;
public:
void dump (void) const;
// Dump the state of an object.
ACE_ALLOC_HOOK_DECLARE;
// Declare the dynamic allocation hooks.
private:
char *end_;
char *cur_;
ACE_Obchunk *next_;
char contents_[4];
};
class ACE_Export ACE_Obstack
{
// = TITLE
// Define a simple "mark and release" memory allocation utility.
// This class is based on the GNU obstack utility.
public:
// = Initialization and termination methods.
ACE_Obstack (int size = 4080);
~ACE_Obstack (void);
char *copy (const char* data, size_t len);
// Copy the data into the current Obchunk.
void release (void);
// "Release" the entire stack (without freeing it).
void dump (void) const;
// Dump the state of an object.
ACE_ALLOC_HOOK_DECLARE;
// Declare the dynamic allocation hooks.
protected:
class ACE_Obchunk *new_chunk (void);
size_t size_;
// Current size of the Obstack;
class ACE_Obchunk *head_;
// Head of the Obchunk chain.
class ACE_Obchunk *curr_;
// Pointer to the current Obchunk.
};
#endif /* ACE_OBSTACK_H */
|