~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201207201942

« back to all changes in this revision

Viewing changes to lib/include/dynbuf.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-03-20 10:19:00 UTC
  • mfrom: (1.1.4 upstream) (2.4.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090320101900-1o604camiubq2de8
Tags: 2009.03.18-154848-2
Correcting patch system depends (Closes: #520493).

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
#include <string.h>
29
29
#include "vm_basic_types.h"
 
30
#include "vm_assert.h"
30
31
 
31
32
 
32
33
typedef struct DynBuf {
43
44
DynBuf_Destroy(DynBuf *b); // IN
44
45
 
45
46
void *
46
 
DynBuf_Get(DynBuf const *b); // IN
47
 
 
48
 
void *
49
47
DynBuf_AllocGet(DynBuf const *b); // IN
50
48
 
51
49
void
68
66
Bool
69
67
DynBuf_Trim(DynBuf *b); // IN
70
68
 
71
 
size_t
72
 
DynBuf_GetSize(DynBuf const *b); // IN
73
 
 
74
 
void
75
 
DynBuf_SetSize(DynBuf *b,    // IN
76
 
               size_t size); // IN
77
 
 
78
 
size_t
79
 
DynBuf_GetAllocatedSize(DynBuf const *b); // IN
80
 
 
81
69
Bool
82
70
DynBuf_Copy(DynBuf *src,    // IN
83
71
            DynBuf *dest);  // OUT
84
72
 
85
73
 
86
74
/*
 
75
 *-----------------------------------------------------------------------------
 
76
 *
 
77
 * DynBuf_Get --
 
78
 *
 
79
 *      Retrieve a pointer to the data contained in a dynamic buffer --hpreg
 
80
 *
 
81
 * Results:
 
82
 *      The pointer to the data
 
83
 *
 
84
 * Side effects:
 
85
 *      None
 
86
 *
 
87
 *-----------------------------------------------------------------------------
 
88
 */
 
89
 
 
90
static INLINE void *
 
91
DynBuf_Get(DynBuf const *b) // IN
 
92
{
 
93
   ASSERT(b);
 
94
 
 
95
   return b->data;
 
96
}
 
97
 
 
98
 
 
99
/*
 
100
 *-----------------------------------------------------------------------------
 
101
 *
 
102
 * DynBuf_GetSize --
 
103
 *
 
104
 *      Returns the current size of the dynamic buffer --hpreg
 
105
 *
 
106
 * Results:
 
107
 *      The current size of the dynamic buffer
 
108
 *
 
109
 * Side effects:
 
110
 *      None
 
111
 *
 
112
 *-----------------------------------------------------------------------------
 
113
 */
 
114
 
 
115
static INLINE size_t
 
116
DynBuf_GetSize(DynBuf const *b) // IN
 
117
{
 
118
   ASSERT(b);
 
119
 
 
120
   return b->size;
 
121
}
 
122
 
 
123
 
 
124
/*
 
125
 *-----------------------------------------------------------------------------
 
126
 *
 
127
 * DynBuf_SetSize --
 
128
 *
 
129
 *      Set the current size of a dynamic buffer --hpreg
 
130
 *
 
131
 * Results:
 
132
 *      None
 
133
 *
 
134
 * Side effects:
 
135
 *      None
 
136
 *
 
137
 *-----------------------------------------------------------------------------
 
138
 */
 
139
 
 
140
static INLINE void
 
141
DynBuf_SetSize(DynBuf *b,   // IN
 
142
               size_t size) // IN
 
143
{
 
144
   ASSERT(b);
 
145
   ASSERT(size <= b->allocated);
 
146
 
 
147
   b->size = size;
 
148
}
 
149
 
 
150
 
 
151
/*
 
152
 *-----------------------------------------------------------------------------
 
153
 *
 
154
 * DynBuf_GetAllocatedSize --
 
155
 *
 
156
 *      Returns the current allocated size of the dynamic buffer --hpreg
 
157
 *
 
158
 * Results:
 
159
 *      The current allocated size of the dynamic buffer
 
160
 *
 
161
 * Side effects:
 
162
 *      None
 
163
 *
 
164
 *-----------------------------------------------------------------------------
 
165
 */
 
166
 
 
167
static INLINE size_t
 
168
DynBuf_GetAllocatedSize(DynBuf const *b) // IN
 
169
{
 
170
   ASSERT(b);
 
171
 
 
172
   return b->allocated;
 
173
}
 
174
 
 
175
 
 
176
/*
87
177
 *----------------------------------------------------------------------------
88
178
 *
89
179
 * DynBuf_AppendString --