line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/* |
2
|
|
|
|
|
|
|
* ***** BEGIN LICENSE BLOCK ***** |
3
|
|
|
|
|
|
|
* Version: MIT |
4
|
|
|
|
|
|
|
* |
5
|
|
|
|
|
|
|
* Portions created by Alan Antonuk are Copyright (c) 2012-2013 |
6
|
|
|
|
|
|
|
* Alan Antonuk. All Rights Reserved. |
7
|
|
|
|
|
|
|
* |
8
|
|
|
|
|
|
|
* Portions created by VMware are Copyright (c) 2007-2012 VMware, Inc. |
9
|
|
|
|
|
|
|
* All Rights Reserved. |
10
|
|
|
|
|
|
|
* |
11
|
|
|
|
|
|
|
* Portions created by Tony Garnock-Jones are Copyright (c) 2009-2010 |
12
|
|
|
|
|
|
|
* VMware, Inc. and Tony Garnock-Jones. All Rights Reserved. |
13
|
|
|
|
|
|
|
* |
14
|
|
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person |
15
|
|
|
|
|
|
|
* obtaining a copy of this software and associated documentation |
16
|
|
|
|
|
|
|
* files (the "Software"), to deal in the Software without |
17
|
|
|
|
|
|
|
* restriction, including without limitation the rights to use, copy, |
18
|
|
|
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies |
19
|
|
|
|
|
|
|
* of the Software, and to permit persons to whom the Software is |
20
|
|
|
|
|
|
|
* furnished to do so, subject to the following conditions: |
21
|
|
|
|
|
|
|
* |
22
|
|
|
|
|
|
|
* The above copyright notice and this permission notice shall be |
23
|
|
|
|
|
|
|
* included in all copies or substantial portions of the Software. |
24
|
|
|
|
|
|
|
* |
25
|
|
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
26
|
|
|
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
27
|
|
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
28
|
|
|
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
29
|
|
|
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
30
|
|
|
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
31
|
|
|
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
32
|
|
|
|
|
|
|
* SOFTWARE. |
33
|
|
|
|
|
|
|
* ***** END LICENSE BLOCK ***** |
34
|
|
|
|
|
|
|
*/ |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H |
37
|
|
|
|
|
|
|
#include "config.h" |
38
|
|
|
|
|
|
|
#endif |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#include "amqp_private.h" |
41
|
|
|
|
|
|
|
#include "amqp_table.h" |
42
|
|
|
|
|
|
|
#include |
43
|
|
|
|
|
|
|
#include |
44
|
|
|
|
|
|
|
#include |
45
|
|
|
|
|
|
|
#include |
46
|
|
|
|
|
|
|
#include |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
#define INITIAL_ARRAY_SIZE 16 |
49
|
|
|
|
|
|
|
#define INITIAL_TABLE_SIZE 16 |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
static int amqp_decode_field_value(amqp_bytes_t encoded, amqp_pool_t *pool, |
52
|
|
|
|
|
|
|
amqp_field_value_t *entry, size_t *offset); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
static int amqp_encode_field_value(amqp_bytes_t encoded, |
55
|
|
|
|
|
|
|
amqp_field_value_t *entry, size_t *offset); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/ |
58
|
|
|
|
|
|
|
|
59
|
5
|
|
|
|
|
|
static int amqp_decode_array(amqp_bytes_t encoded, amqp_pool_t *pool, |
60
|
|
|
|
|
|
|
amqp_array_t *output, size_t *offset) { |
61
|
|
|
|
|
|
|
uint32_t arraysize; |
62
|
5
|
|
|
|
|
|
int num_entries = 0; |
63
|
5
|
|
|
|
|
|
int allocated_entries = INITIAL_ARRAY_SIZE; |
64
|
|
|
|
|
|
|
amqp_field_value_t *entries; |
65
|
|
|
|
|
|
|
size_t limit; |
66
|
|
|
|
|
|
|
int res; |
67
|
|
|
|
|
|
|
|
68
|
5
|
50
|
|
|
|
|
if (!amqp_decode_32(encoded, offset, &arraysize)) { |
69
|
0
|
|
|
|
|
|
return AMQP_STATUS_BAD_AMQP_DATA; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
5
|
50
|
|
|
|
|
if (arraysize + *offset > encoded.len) { |
73
|
0
|
|
|
|
|
|
return AMQP_STATUS_BAD_AMQP_DATA; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
5
|
|
|
|
|
|
entries = malloc(allocated_entries * sizeof(amqp_field_value_t)); |
77
|
5
|
50
|
|
|
|
|
if (entries == NULL) { |
78
|
0
|
|
|
|
|
|
return AMQP_STATUS_NO_MEMORY; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
5
|
|
|
|
|
|
limit = *offset + arraysize; |
82
|
119
|
100
|
|
|
|
|
while (*offset < limit) { |
83
|
114
|
100
|
|
|
|
|
if (num_entries >= allocated_entries) { |
84
|
|
|
|
|
|
|
void *newentries; |
85
|
3
|
|
|
|
|
|
allocated_entries = allocated_entries * 2; |
86
|
3
|
|
|
|
|
|
newentries = |
87
|
3
|
|
|
|
|
|
realloc(entries, allocated_entries * sizeof(amqp_field_value_t)); |
88
|
3
|
|
|
|
|
|
res = AMQP_STATUS_NO_MEMORY; |
89
|
3
|
50
|
|
|
|
|
if (newentries == NULL) { |
90
|
0
|
|
|
|
|
|
goto out; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
3
|
|
|
|
|
|
entries = newentries; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
114
|
|
|
|
|
|
res = amqp_decode_field_value(encoded, pool, &entries[num_entries], offset); |
97
|
114
|
50
|
|
|
|
|
if (res < 0) { |
98
|
0
|
|
|
|
|
|
goto out; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
114
|
|
|
|
|
|
num_entries++; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
5
|
|
|
|
|
|
output->num_entries = num_entries; |
105
|
5
|
|
|
|
|
|
output->entries = |
106
|
5
|
|
|
|
|
|
amqp_pool_alloc(pool, num_entries * sizeof(amqp_field_value_t)); |
107
|
|
|
|
|
|
|
/* NULL is legitimate if we requested a zero-length block. */ |
108
|
5
|
50
|
|
|
|
|
if (output->entries == NULL) { |
109
|
0
|
0
|
|
|
|
|
if (num_entries == 0) { |
110
|
0
|
|
|
|
|
|
res = AMQP_STATUS_OK; |
111
|
|
|
|
|
|
|
} else { |
112
|
0
|
|
|
|
|
|
res = AMQP_STATUS_NO_MEMORY; |
113
|
|
|
|
|
|
|
} |
114
|
0
|
|
|
|
|
|
goto out; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
5
|
|
|
|
|
|
memcpy(output->entries, entries, num_entries * sizeof(amqp_field_value_t)); |
118
|
5
|
|
|
|
|
|
res = AMQP_STATUS_OK; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
out: |
121
|
5
|
|
|
|
|
|
free(entries); |
122
|
5
|
|
|
|
|
|
return res; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
90
|
|
|
|
|
|
int amqp_decode_table(amqp_bytes_t encoded, amqp_pool_t *pool, |
126
|
|
|
|
|
|
|
amqp_table_t *output, size_t *offset) { |
127
|
|
|
|
|
|
|
uint32_t tablesize; |
128
|
90
|
|
|
|
|
|
int num_entries = 0; |
129
|
|
|
|
|
|
|
amqp_table_entry_t *entries; |
130
|
90
|
|
|
|
|
|
int allocated_entries = INITIAL_TABLE_SIZE; |
131
|
|
|
|
|
|
|
size_t limit; |
132
|
|
|
|
|
|
|
int res; |
133
|
|
|
|
|
|
|
|
134
|
90
|
50
|
|
|
|
|
if (!amqp_decode_32(encoded, offset, &tablesize)) { |
135
|
0
|
|
|
|
|
|
return AMQP_STATUS_BAD_AMQP_DATA; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
90
|
50
|
|
|
|
|
if (tablesize + *offset > encoded.len) { |
139
|
0
|
|
|
|
|
|
return AMQP_STATUS_BAD_AMQP_DATA; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
90
|
|
|
|
|
|
entries = malloc(allocated_entries * sizeof(amqp_table_entry_t)); |
143
|
90
|
50
|
|
|
|
|
if (entries == NULL) { |
144
|
0
|
|
|
|
|
|
return AMQP_STATUS_NO_MEMORY; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
90
|
|
|
|
|
|
limit = *offset + tablesize; |
148
|
742
|
100
|
|
|
|
|
while (*offset < limit) { |
149
|
|
|
|
|
|
|
uint8_t keylen; |
150
|
|
|
|
|
|
|
|
151
|
652
|
|
|
|
|
|
res = AMQP_STATUS_BAD_AMQP_DATA; |
152
|
652
|
50
|
|
|
|
|
if (!amqp_decode_8(encoded, offset, &keylen)) { |
153
|
0
|
|
|
|
|
|
goto out; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
652
|
50
|
|
|
|
|
if (num_entries >= allocated_entries) { |
157
|
|
|
|
|
|
|
void *newentries; |
158
|
0
|
|
|
|
|
|
allocated_entries = allocated_entries * 2; |
159
|
0
|
|
|
|
|
|
newentries = |
160
|
0
|
|
|
|
|
|
realloc(entries, allocated_entries * sizeof(amqp_table_entry_t)); |
161
|
0
|
|
|
|
|
|
res = AMQP_STATUS_NO_MEMORY; |
162
|
0
|
0
|
|
|
|
|
if (newentries == NULL) { |
163
|
0
|
|
|
|
|
|
goto out; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
entries = newentries; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
652
|
|
|
|
|
|
res = AMQP_STATUS_BAD_AMQP_DATA; |
170
|
652
|
50
|
|
|
|
|
if (!amqp_decode_bytes(encoded, offset, &entries[num_entries].key, |
171
|
|
|
|
|
|
|
keylen)) { |
172
|
0
|
|
|
|
|
|
goto out; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
652
|
|
|
|
|
|
res = amqp_decode_field_value(encoded, pool, &entries[num_entries].value, |
176
|
|
|
|
|
|
|
offset); |
177
|
652
|
50
|
|
|
|
|
if (res < 0) { |
178
|
0
|
|
|
|
|
|
goto out; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
652
|
|
|
|
|
|
num_entries++; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
90
|
|
|
|
|
|
output->num_entries = num_entries; |
185
|
90
|
|
|
|
|
|
output->entries = |
186
|
90
|
|
|
|
|
|
amqp_pool_alloc(pool, num_entries * sizeof(amqp_table_entry_t)); |
187
|
|
|
|
|
|
|
/* NULL is legitimate if we requested a zero-length block. */ |
188
|
90
|
50
|
|
|
|
|
if (output->entries == NULL) { |
189
|
0
|
0
|
|
|
|
|
if (num_entries == 0) { |
190
|
0
|
|
|
|
|
|
res = AMQP_STATUS_OK; |
191
|
|
|
|
|
|
|
} else { |
192
|
0
|
|
|
|
|
|
res = AMQP_STATUS_NO_MEMORY; |
193
|
|
|
|
|
|
|
} |
194
|
0
|
|
|
|
|
|
goto out; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
90
|
|
|
|
|
|
memcpy(output->entries, entries, num_entries * sizeof(amqp_table_entry_t)); |
198
|
90
|
|
|
|
|
|
res = AMQP_STATUS_OK; |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
out: |
201
|
90
|
|
|
|
|
|
free(entries); |
202
|
90
|
|
|
|
|
|
return res; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
766
|
|
|
|
|
|
static int amqp_decode_field_value(amqp_bytes_t encoded, amqp_pool_t *pool, |
206
|
|
|
|
|
|
|
amqp_field_value_t *entry, size_t *offset) { |
207
|
766
|
|
|
|
|
|
int res = AMQP_STATUS_BAD_AMQP_DATA; |
208
|
|
|
|
|
|
|
|
209
|
766
|
50
|
|
|
|
|
if (!amqp_decode_8(encoded, offset, &entry->kind)) { |
210
|
0
|
|
|
|
|
|
goto out; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
#define TRIVIAL_FIELD_DECODER(bits) \ |
214
|
|
|
|
|
|
|
if (!amqp_decode_##bits(encoded, offset, &entry->value.u##bits)) goto out; \ |
215
|
|
|
|
|
|
|
break |
216
|
|
|
|
|
|
|
#define SIMPLE_FIELD_DECODER(bits, dest, how) \ |
217
|
|
|
|
|
|
|
{ \ |
218
|
|
|
|
|
|
|
uint##bits##_t val; \ |
219
|
|
|
|
|
|
|
if (!amqp_decode_##bits(encoded, offset, &val)) goto out; \ |
220
|
|
|
|
|
|
|
entry->value.dest = how; \ |
221
|
|
|
|
|
|
|
} \ |
222
|
|
|
|
|
|
|
break |
223
|
|
|
|
|
|
|
|
224
|
766
|
|
|
|
|
|
switch (entry->kind) { |
225
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_BOOLEAN: |
226
|
342
|
50
|
|
|
|
|
SIMPLE_FIELD_DECODER(8, boolean, val ? 1 : 0); |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_I8: |
229
|
0
|
0
|
|
|
|
|
SIMPLE_FIELD_DECODER(8, i8, (int8_t)val); |
230
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_U8: |
231
|
0
|
0
|
|
|
|
|
TRIVIAL_FIELD_DECODER(8); |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_I16: |
234
|
0
|
0
|
|
|
|
|
SIMPLE_FIELD_DECODER(16, i16, (int16_t)val); |
235
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_U16: |
236
|
0
|
0
|
|
|
|
|
TRIVIAL_FIELD_DECODER(16); |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_I32: |
239
|
0
|
0
|
|
|
|
|
SIMPLE_FIELD_DECODER(32, i32, (int32_t)val); |
240
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_U32: |
241
|
0
|
0
|
|
|
|
|
TRIVIAL_FIELD_DECODER(32); |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_I64: |
244
|
122
|
50
|
|
|
|
|
SIMPLE_FIELD_DECODER(64, i64, (int64_t)val); |
245
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_U64: |
246
|
0
|
0
|
|
|
|
|
TRIVIAL_FIELD_DECODER(64); |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_F32: |
249
|
0
|
0
|
|
|
|
|
TRIVIAL_FIELD_DECODER(32); |
250
|
|
|
|
|
|
|
/* and by punning, f32 magically gets the right value...! */ |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_F64: |
253
|
2
|
50
|
|
|
|
|
TRIVIAL_FIELD_DECODER(64); |
254
|
|
|
|
|
|
|
/* and by punning, f64 magically gets the right value...! */ |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_DECIMAL: |
257
|
0
|
|
|
|
|
|
if (!amqp_decode_8(encoded, offset, &entry->value.decimal.decimals) || |
258
|
0
|
|
|
|
|
|
!amqp_decode_32(encoded, offset, &entry->value.decimal.value)) { |
259
|
|
|
|
|
|
|
goto out; |
260
|
|
|
|
|
|
|
} |
261
|
0
|
|
|
|
|
|
break; |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_UTF8: |
264
|
|
|
|
|
|
|
/* AMQP_FIELD_KIND_UTF8 and AMQP_FIELD_KIND_BYTES have the |
265
|
|
|
|
|
|
|
same implementation, but different interpretations. */ |
266
|
|
|
|
|
|
|
/* fall through */ |
267
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_BYTES: { |
268
|
|
|
|
|
|
|
uint32_t len; |
269
|
504
|
|
|
|
|
|
if (!amqp_decode_32(encoded, offset, &len) || |
270
|
252
|
|
|
|
|
|
!amqp_decode_bytes(encoded, offset, &entry->value.bytes, len)) { |
271
|
|
|
|
|
|
|
goto out; |
272
|
|
|
|
|
|
|
} |
273
|
252
|
|
|
|
|
|
break; |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_ARRAY: |
277
|
5
|
|
|
|
|
|
res = amqp_decode_array(encoded, pool, &(entry->value.array), offset); |
278
|
5
|
|
|
|
|
|
goto out; |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_TIMESTAMP: |
281
|
0
|
0
|
|
|
|
|
TRIVIAL_FIELD_DECODER(64); |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_TABLE: |
284
|
43
|
|
|
|
|
|
res = amqp_decode_table(encoded, pool, &(entry->value.table), offset); |
285
|
43
|
|
|
|
|
|
goto out; |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_VOID: |
288
|
0
|
|
|
|
|
|
break; |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
default: |
291
|
0
|
|
|
|
|
|
goto out; |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
718
|
|
|
|
|
|
res = AMQP_STATUS_OK; |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
out: |
297
|
766
|
|
|
|
|
|
return res; |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/ |
301
|
|
|
|
|
|
|
|
302
|
5
|
|
|
|
|
|
static int amqp_encode_array(amqp_bytes_t encoded, amqp_array_t *input, |
303
|
|
|
|
|
|
|
size_t *offset) { |
304
|
5
|
|
|
|
|
|
size_t start = *offset; |
305
|
|
|
|
|
|
|
int i, res; |
306
|
|
|
|
|
|
|
|
307
|
5
|
|
|
|
|
|
*offset += 4; /* size of the array gets filled in later on */ |
308
|
|
|
|
|
|
|
|
309
|
119
|
100
|
|
|
|
|
for (i = 0; i < input->num_entries; i++) { |
310
|
114
|
|
|
|
|
|
res = amqp_encode_field_value(encoded, &input->entries[i], offset); |
311
|
114
|
50
|
|
|
|
|
if (res < 0) { |
312
|
0
|
|
|
|
|
|
goto out; |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
} |
315
|
|
|
|
|
|
|
|
316
|
5
|
50
|
|
|
|
|
if (!amqp_encode_32(encoded, &start, (uint32_t)(*offset - start - 4))) { |
317
|
0
|
|
|
|
|
|
res = AMQP_STATUS_TABLE_TOO_BIG; |
318
|
0
|
|
|
|
|
|
goto out; |
319
|
|
|
|
|
|
|
} |
320
|
|
|
|
|
|
|
|
321
|
5
|
|
|
|
|
|
res = AMQP_STATUS_OK; |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
out: |
324
|
5
|
|
|
|
|
|
return res; |
325
|
|
|
|
|
|
|
} |
326
|
|
|
|
|
|
|
|
327
|
193
|
|
|
|
|
|
int amqp_encode_table(amqp_bytes_t encoded, amqp_table_t *input, |
328
|
|
|
|
|
|
|
size_t *offset) { |
329
|
193
|
|
|
|
|
|
size_t start = *offset; |
330
|
|
|
|
|
|
|
int i, res; |
331
|
|
|
|
|
|
|
|
332
|
193
|
|
|
|
|
|
*offset += 4; /* size of the table gets filled in later on */ |
333
|
|
|
|
|
|
|
|
334
|
553
|
100
|
|
|
|
|
for (i = 0; i < input->num_entries; i++) { |
335
|
360
|
50
|
|
|
|
|
if (!amqp_encode_8(encoded, offset, (uint8_t)input->entries[i].key.len)) { |
336
|
0
|
|
|
|
|
|
res = AMQP_STATUS_TABLE_TOO_BIG; |
337
|
0
|
|
|
|
|
|
goto out; |
338
|
|
|
|
|
|
|
} |
339
|
|
|
|
|
|
|
|
340
|
360
|
50
|
|
|
|
|
if (!amqp_encode_bytes(encoded, offset, input->entries[i].key)) { |
341
|
0
|
|
|
|
|
|
res = AMQP_STATUS_TABLE_TOO_BIG; |
342
|
0
|
|
|
|
|
|
goto out; |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
|
345
|
360
|
|
|
|
|
|
res = amqp_encode_field_value(encoded, &input->entries[i].value, offset); |
346
|
360
|
50
|
|
|
|
|
if (res < 0) { |
347
|
0
|
|
|
|
|
|
goto out; |
348
|
|
|
|
|
|
|
} |
349
|
|
|
|
|
|
|
} |
350
|
|
|
|
|
|
|
|
351
|
193
|
50
|
|
|
|
|
if (!amqp_encode_32(encoded, &start, (uint32_t)(*offset - start - 4))) { |
352
|
0
|
|
|
|
|
|
res = AMQP_STATUS_TABLE_TOO_BIG; |
353
|
0
|
|
|
|
|
|
goto out; |
354
|
|
|
|
|
|
|
} |
355
|
|
|
|
|
|
|
|
356
|
193
|
|
|
|
|
|
res = AMQP_STATUS_OK; |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
out: |
359
|
193
|
|
|
|
|
|
return res; |
360
|
|
|
|
|
|
|
} |
361
|
|
|
|
|
|
|
|
362
|
474
|
|
|
|
|
|
static int amqp_encode_field_value(amqp_bytes_t encoded, |
363
|
|
|
|
|
|
|
amqp_field_value_t *entry, size_t *offset) { |
364
|
474
|
|
|
|
|
|
int res = AMQP_STATUS_BAD_AMQP_DATA; |
365
|
|
|
|
|
|
|
|
366
|
474
|
50
|
|
|
|
|
if (!amqp_encode_8(encoded, offset, entry->kind)) { |
367
|
0
|
|
|
|
|
|
goto out; |
368
|
|
|
|
|
|
|
} |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
#define FIELD_ENCODER(bits, val) \ |
371
|
|
|
|
|
|
|
if (!amqp_encode_##bits(encoded, offset, val)) { \ |
372
|
|
|
|
|
|
|
res = AMQP_STATUS_TABLE_TOO_BIG; \ |
373
|
|
|
|
|
|
|
goto out; \ |
374
|
|
|
|
|
|
|
} \ |
375
|
|
|
|
|
|
|
break |
376
|
|
|
|
|
|
|
|
377
|
474
|
|
|
|
|
|
switch (entry->kind) { |
378
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_BOOLEAN: |
379
|
76
|
50
|
|
|
|
|
FIELD_ENCODER(8, entry->value.boolean ? 1 : 0); |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_I8: |
382
|
0
|
0
|
|
|
|
|
FIELD_ENCODER(8, entry->value.i8); |
383
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_U8: |
384
|
0
|
0
|
|
|
|
|
FIELD_ENCODER(8, entry->value.u8); |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_I16: |
387
|
0
|
0
|
|
|
|
|
FIELD_ENCODER(16, entry->value.i16); |
388
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_U16: |
389
|
0
|
0
|
|
|
|
|
FIELD_ENCODER(16, entry->value.u16); |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_I32: |
392
|
0
|
0
|
|
|
|
|
FIELD_ENCODER(32, entry->value.i32); |
393
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_U32: |
394
|
0
|
0
|
|
|
|
|
FIELD_ENCODER(32, entry->value.u32); |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_I64: |
397
|
124
|
50
|
|
|
|
|
FIELD_ENCODER(64, entry->value.i64); |
398
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_U64: |
399
|
0
|
0
|
|
|
|
|
FIELD_ENCODER(64, entry->value.u64); |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_F32: |
402
|
|
|
|
|
|
|
/* by punning, u32 magically gets the right value...! */ |
403
|
0
|
0
|
|
|
|
|
FIELD_ENCODER(32, entry->value.u32); |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_F64: |
406
|
|
|
|
|
|
|
/* by punning, u64 magically gets the right value...! */ |
407
|
2
|
50
|
|
|
|
|
FIELD_ENCODER(64, entry->value.u64); |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_DECIMAL: |
410
|
0
|
|
|
|
|
|
if (!amqp_encode_8(encoded, offset, entry->value.decimal.decimals) || |
411
|
0
|
|
|
|
|
|
!amqp_encode_32(encoded, offset, entry->value.decimal.value)) { |
412
|
0
|
|
|
|
|
|
res = AMQP_STATUS_TABLE_TOO_BIG; |
413
|
0
|
|
|
|
|
|
goto out; |
414
|
|
|
|
|
|
|
} |
415
|
0
|
|
|
|
|
|
break; |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_UTF8: |
418
|
|
|
|
|
|
|
/* AMQP_FIELD_KIND_UTF8 and AMQP_FIELD_KIND_BYTES have the |
419
|
|
|
|
|
|
|
same implementation, but different interpretations. */ |
420
|
|
|
|
|
|
|
/* fall through */ |
421
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_BYTES: |
422
|
448
|
|
|
|
|
|
if (!amqp_encode_32(encoded, offset, (uint32_t)entry->value.bytes.len) || |
423
|
224
|
|
|
|
|
|
!amqp_encode_bytes(encoded, offset, entry->value.bytes)) { |
424
|
0
|
|
|
|
|
|
res = AMQP_STATUS_TABLE_TOO_BIG; |
425
|
0
|
|
|
|
|
|
goto out; |
426
|
|
|
|
|
|
|
} |
427
|
224
|
|
|
|
|
|
break; |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_ARRAY: |
430
|
5
|
|
|
|
|
|
res = amqp_encode_array(encoded, &entry->value.array, offset); |
431
|
5
|
|
|
|
|
|
goto out; |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_TIMESTAMP: |
434
|
0
|
0
|
|
|
|
|
FIELD_ENCODER(64, entry->value.u64); |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_TABLE: |
437
|
43
|
|
|
|
|
|
res = amqp_encode_table(encoded, &entry->value.table, offset); |
438
|
43
|
|
|
|
|
|
goto out; |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_VOID: |
441
|
0
|
|
|
|
|
|
break; |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
default: |
444
|
0
|
|
|
|
|
|
res = AMQP_STATUS_INVALID_PARAMETER; |
445
|
0
|
|
|
|
|
|
goto out; |
446
|
|
|
|
|
|
|
} |
447
|
|
|
|
|
|
|
|
448
|
426
|
|
|
|
|
|
res = AMQP_STATUS_OK; |
449
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
out: |
451
|
474
|
|
|
|
|
|
return res; |
452
|
|
|
|
|
|
|
} |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/ |
455
|
|
|
|
|
|
|
|
456
|
0
|
|
|
|
|
|
int amqp_table_entry_cmp(void const *entry1, void const *entry2) { |
457
|
0
|
|
|
|
|
|
amqp_table_entry_t const *p1 = (amqp_table_entry_t const *)entry1; |
458
|
0
|
|
|
|
|
|
amqp_table_entry_t const *p2 = (amqp_table_entry_t const *)entry2; |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
int d; |
461
|
|
|
|
|
|
|
size_t minlen; |
462
|
|
|
|
|
|
|
|
463
|
0
|
|
|
|
|
|
minlen = p1->key.len; |
464
|
0
|
0
|
|
|
|
|
if (p2->key.len < minlen) { |
465
|
0
|
|
|
|
|
|
minlen = p2->key.len; |
466
|
|
|
|
|
|
|
} |
467
|
|
|
|
|
|
|
|
468
|
0
|
|
|
|
|
|
d = memcmp(p1->key.bytes, p2->key.bytes, minlen); |
469
|
0
|
0
|
|
|
|
|
if (d != 0) { |
470
|
0
|
|
|
|
|
|
return d; |
471
|
|
|
|
|
|
|
} |
472
|
|
|
|
|
|
|
|
473
|
0
|
|
|
|
|
|
return (int)p1->key.len - (int)p2->key.len; |
474
|
|
|
|
|
|
|
} |
475
|
|
|
|
|
|
|
|
476
|
913
|
|
|
|
|
|
static int amqp_field_value_clone(const amqp_field_value_t *original, |
477
|
|
|
|
|
|
|
amqp_field_value_t *clone, |
478
|
|
|
|
|
|
|
amqp_pool_t *pool) { |
479
|
|
|
|
|
|
|
int i; |
480
|
|
|
|
|
|
|
int res; |
481
|
913
|
|
|
|
|
|
clone->kind = original->kind; |
482
|
|
|
|
|
|
|
|
483
|
913
|
|
|
|
|
|
switch (clone->kind) { |
484
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_BOOLEAN: |
485
|
418
|
|
|
|
|
|
clone->value.boolean = original->value.boolean; |
486
|
418
|
|
|
|
|
|
break; |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_I8: |
489
|
0
|
|
|
|
|
|
clone->value.i8 = original->value.i8; |
490
|
0
|
|
|
|
|
|
break; |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_U8: |
493
|
0
|
|
|
|
|
|
clone->value.u8 = original->value.u8; |
494
|
0
|
|
|
|
|
|
break; |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_I16: |
497
|
0
|
|
|
|
|
|
clone->value.i16 = original->value.i16; |
498
|
0
|
|
|
|
|
|
break; |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_U16: |
501
|
0
|
|
|
|
|
|
clone->value.u16 = original->value.u16; |
502
|
0
|
|
|
|
|
|
break; |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_I32: |
505
|
0
|
|
|
|
|
|
clone->value.i32 = original->value.i32; |
506
|
0
|
|
|
|
|
|
break; |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_U32: |
509
|
0
|
|
|
|
|
|
clone->value.u32 = original->value.u32; |
510
|
0
|
|
|
|
|
|
break; |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_I64: |
513
|
0
|
|
|
|
|
|
clone->value.i64 = original->value.i64; |
514
|
0
|
|
|
|
|
|
break; |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_U64: |
517
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_TIMESTAMP: |
518
|
0
|
|
|
|
|
|
clone->value.u64 = original->value.u64; |
519
|
0
|
|
|
|
|
|
break; |
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_F32: |
522
|
0
|
|
|
|
|
|
clone->value.f32 = original->value.f32; |
523
|
0
|
|
|
|
|
|
break; |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_F64: |
526
|
0
|
|
|
|
|
|
clone->value.f64 = original->value.f64; |
527
|
0
|
|
|
|
|
|
break; |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_DECIMAL: |
530
|
0
|
|
|
|
|
|
clone->value.decimal = original->value.decimal; |
531
|
0
|
|
|
|
|
|
break; |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_UTF8: |
534
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_BYTES: |
535
|
419
|
50
|
|
|
|
|
if (0 == original->value.bytes.len) { |
536
|
0
|
|
|
|
|
|
clone->value.bytes = amqp_empty_bytes; |
537
|
|
|
|
|
|
|
} else { |
538
|
419
|
|
|
|
|
|
amqp_pool_alloc_bytes(pool, original->value.bytes.len, |
539
|
|
|
|
|
|
|
&clone->value.bytes); |
540
|
419
|
50
|
|
|
|
|
if (NULL == clone->value.bytes.bytes) { |
541
|
0
|
|
|
|
|
|
return AMQP_STATUS_NO_MEMORY; |
542
|
|
|
|
|
|
|
} |
543
|
419
|
|
|
|
|
|
memcpy(clone->value.bytes.bytes, original->value.bytes.bytes, |
544
|
|
|
|
|
|
|
clone->value.bytes.len); |
545
|
|
|
|
|
|
|
} |
546
|
419
|
|
|
|
|
|
break; |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_ARRAY: |
549
|
0
|
0
|
|
|
|
|
if (0 == original->value.array.entries) { |
550
|
0
|
|
|
|
|
|
clone->value.array = amqp_empty_array; |
551
|
|
|
|
|
|
|
} else { |
552
|
0
|
|
|
|
|
|
clone->value.array.num_entries = original->value.array.num_entries; |
553
|
0
|
|
|
|
|
|
clone->value.array.entries = amqp_pool_alloc( |
554
|
0
|
|
|
|
|
|
pool, clone->value.array.num_entries * sizeof(amqp_field_value_t)); |
555
|
0
|
0
|
|
|
|
|
if (NULL == clone->value.array.entries) { |
556
|
0
|
|
|
|
|
|
return AMQP_STATUS_NO_MEMORY; |
557
|
|
|
|
|
|
|
} |
558
|
|
|
|
|
|
|
|
559
|
0
|
0
|
|
|
|
|
for (i = 0; i < clone->value.array.num_entries; ++i) { |
560
|
0
|
|
|
|
|
|
res = amqp_field_value_clone(&original->value.array.entries[i], |
561
|
0
|
|
|
|
|
|
&clone->value.array.entries[i], pool); |
562
|
0
|
0
|
|
|
|
|
if (AMQP_STATUS_OK != res) { |
563
|
0
|
|
|
|
|
|
return res; |
564
|
|
|
|
|
|
|
} |
565
|
|
|
|
|
|
|
} |
566
|
|
|
|
|
|
|
} |
567
|
0
|
|
|
|
|
|
break; |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_TABLE: |
570
|
76
|
|
|
|
|
|
return amqp_table_clone(&original->value.table, &clone->value.table, |
571
|
|
|
|
|
|
|
pool); |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
case AMQP_FIELD_KIND_VOID: |
574
|
0
|
|
|
|
|
|
break; |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
default: |
577
|
0
|
|
|
|
|
|
return AMQP_STATUS_INVALID_PARAMETER; |
578
|
|
|
|
|
|
|
} |
579
|
|
|
|
|
|
|
|
580
|
837
|
|
|
|
|
|
return AMQP_STATUS_OK; |
581
|
|
|
|
|
|
|
} |
582
|
|
|
|
|
|
|
|
583
|
913
|
|
|
|
|
|
static int amqp_table_entry_clone(const amqp_table_entry_t *original, |
584
|
|
|
|
|
|
|
amqp_table_entry_t *clone, |
585
|
|
|
|
|
|
|
amqp_pool_t *pool) { |
586
|
913
|
50
|
|
|
|
|
if (0 == original->key.len) { |
587
|
0
|
|
|
|
|
|
return AMQP_STATUS_INVALID_PARAMETER; |
588
|
|
|
|
|
|
|
} |
589
|
|
|
|
|
|
|
|
590
|
913
|
|
|
|
|
|
amqp_pool_alloc_bytes(pool, original->key.len, &clone->key); |
591
|
913
|
50
|
|
|
|
|
if (NULL == clone->key.bytes) { |
592
|
0
|
|
|
|
|
|
return AMQP_STATUS_NO_MEMORY; |
593
|
|
|
|
|
|
|
} |
594
|
|
|
|
|
|
|
|
595
|
913
|
|
|
|
|
|
memcpy(clone->key.bytes, original->key.bytes, clone->key.len); |
596
|
|
|
|
|
|
|
|
597
|
913
|
|
|
|
|
|
return amqp_field_value_clone(&original->value, &clone->value, pool); |
598
|
|
|
|
|
|
|
} |
599
|
|
|
|
|
|
|
|
600
|
152
|
|
|
|
|
|
int amqp_table_clone(const amqp_table_t *original, amqp_table_t *clone, |
601
|
|
|
|
|
|
|
amqp_pool_t *pool) { |
602
|
|
|
|
|
|
|
int i; |
603
|
|
|
|
|
|
|
int res; |
604
|
152
|
|
|
|
|
|
clone->num_entries = original->num_entries; |
605
|
152
|
50
|
|
|
|
|
if (0 == clone->num_entries) { |
606
|
0
|
|
|
|
|
|
*clone = amqp_empty_table; |
607
|
0
|
|
|
|
|
|
return AMQP_STATUS_OK; |
608
|
|
|
|
|
|
|
} |
609
|
|
|
|
|
|
|
|
610
|
152
|
|
|
|
|
|
clone->entries = |
611
|
152
|
|
|
|
|
|
amqp_pool_alloc(pool, clone->num_entries * sizeof(amqp_table_entry_t)); |
612
|
|
|
|
|
|
|
|
613
|
152
|
50
|
|
|
|
|
if (NULL == clone->entries) { |
614
|
0
|
|
|
|
|
|
return AMQP_STATUS_NO_MEMORY; |
615
|
|
|
|
|
|
|
} |
616
|
|
|
|
|
|
|
|
617
|
1065
|
100
|
|
|
|
|
for (i = 0; i < clone->num_entries; ++i) { |
618
|
913
|
|
|
|
|
|
res = |
619
|
913
|
|
|
|
|
|
amqp_table_entry_clone(&original->entries[i], &clone->entries[i], pool); |
620
|
913
|
50
|
|
|
|
|
if (AMQP_STATUS_OK != res) { |
621
|
0
|
|
|
|
|
|
goto error_out1; |
622
|
|
|
|
|
|
|
} |
623
|
|
|
|
|
|
|
} |
624
|
|
|
|
|
|
|
|
625
|
152
|
|
|
|
|
|
return AMQP_STATUS_OK; |
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
error_out1: |
628
|
0
|
|
|
|
|
|
return res; |
629
|
|
|
|
|
|
|
} |
630
|
|
|
|
|
|
|
|
631
|
190
|
|
|
|
|
|
amqp_table_entry_t amqp_table_construct_utf8_entry(const char *key, |
632
|
|
|
|
|
|
|
const char *value) { |
633
|
|
|
|
|
|
|
amqp_table_entry_t ret; |
634
|
190
|
|
|
|
|
|
ret.key = amqp_cstring_bytes(key); |
635
|
190
|
|
|
|
|
|
ret.value.kind = AMQP_FIELD_KIND_UTF8; |
636
|
190
|
|
|
|
|
|
ret.value.value.bytes = amqp_cstring_bytes(value); |
637
|
190
|
|
|
|
|
|
return ret; |
638
|
|
|
|
|
|
|
} |
639
|
|
|
|
|
|
|
|
640
|
38
|
|
|
|
|
|
amqp_table_entry_t amqp_table_construct_table_entry(const char *key, |
641
|
|
|
|
|
|
|
const amqp_table_t *value) { |
642
|
|
|
|
|
|
|
amqp_table_entry_t ret; |
643
|
38
|
|
|
|
|
|
ret.key = amqp_cstring_bytes(key); |
644
|
38
|
|
|
|
|
|
ret.value.kind = AMQP_FIELD_KIND_TABLE; |
645
|
38
|
|
|
|
|
|
ret.value.value.table = *value; |
646
|
38
|
|
|
|
|
|
return ret; |
647
|
|
|
|
|
|
|
} |
648
|
|
|
|
|
|
|
|
649
|
76
|
|
|
|
|
|
amqp_table_entry_t amqp_table_construct_bool_entry(const char *key, |
650
|
|
|
|
|
|
|
const int value) { |
651
|
|
|
|
|
|
|
amqp_table_entry_t ret; |
652
|
76
|
|
|
|
|
|
ret.key = amqp_cstring_bytes(key); |
653
|
76
|
|
|
|
|
|
ret.value.kind = AMQP_FIELD_KIND_BOOLEAN; |
654
|
76
|
|
|
|
|
|
ret.value.value.boolean = value; |
655
|
76
|
|
|
|
|
|
return ret; |
656
|
|
|
|
|
|
|
} |
657
|
|
|
|
|
|
|
|
658
|
1
|
|
|
|
|
|
amqp_table_entry_t *amqp_table_get_entry_by_key(const amqp_table_t *table, |
659
|
|
|
|
|
|
|
const amqp_bytes_t key) { |
660
|
|
|
|
|
|
|
int i; |
661
|
1
|
50
|
|
|
|
|
assert(table != NULL); |
662
|
7
|
100
|
|
|
|
|
for (i = 0; i < table->num_entries; ++i) { |
663
|
6
|
50
|
|
|
|
|
if (amqp_bytes_equal(table->entries[i].key, key)) { |
664
|
0
|
|
|
|
|
|
return &table->entries[i]; |
665
|
|
|
|
|
|
|
} |
666
|
|
|
|
|
|
|
} |
667
|
1
|
|
|
|
|
|
return NULL; |
668
|
|
|
|
|
|
|
} |