@@ -50,10 +50,8 @@ extern "C" {
50
50
#endif
51
51
52
52
AWS_COMMON_API
53
- int aws_byte_buf_init (
54
- struct aws_allocator * allocator ,
55
- struct aws_byte_buf * buf ,
56
- size_t len );
53
+ int aws_byte_buf_init (struct aws_allocator * allocator , struct aws_byte_buf * buf , size_t len );
54
+
57
55
AWS_COMMON_API
58
56
void aws_byte_buf_clean_up (struct aws_byte_buf * buf );
59
57
@@ -90,10 +88,7 @@ AWS_COMMON_API void aws_byte_buf_secure_clean_up(struct aws_byte_buf *buf);
90
88
* long enough to use the results.
91
89
*/
92
90
AWS_COMMON_API
93
- int aws_byte_buf_split_on_char (
94
- struct aws_byte_buf * input_str ,
95
- char split_on ,
96
- struct aws_array_list * output );
91
+ int aws_byte_buf_split_on_char (struct aws_byte_buf * input_str , char split_on , struct aws_array_list * output );
97
92
98
93
/**
99
94
* No copies, no buffer allocations. Fills in output with a list of
@@ -156,9 +151,7 @@ static inline struct aws_byte_buf aws_byte_buf_from_c_str(const char *c_str) {
156
151
return buf ;
157
152
}
158
153
159
- static inline struct aws_byte_buf aws_byte_buf_from_array (
160
- const uint8_t * bytes ,
161
- size_t len ) {
154
+ static inline struct aws_byte_buf aws_byte_buf_from_array (const uint8_t * bytes , size_t len ) {
162
155
struct aws_byte_buf buf ;
163
156
buf .buffer = (uint8_t * )bytes ;
164
157
buf .len = len ;
@@ -167,17 +160,14 @@ static inline struct aws_byte_buf aws_byte_buf_from_array(
167
160
return buf ;
168
161
}
169
162
170
- static inline struct aws_byte_cursor aws_byte_cursor_from_buf (
171
- const struct aws_byte_buf * buf ) {
163
+ static inline struct aws_byte_cursor aws_byte_cursor_from_buf (const struct aws_byte_buf * buf ) {
172
164
struct aws_byte_cursor cur ;
173
165
cur .ptr = buf -> buffer ;
174
166
cur .len = buf -> len ;
175
167
return cur ;
176
168
}
177
169
178
- static inline struct aws_byte_cursor aws_byte_cursor_from_array (
179
- const void * bytes ,
180
- size_t len ) {
170
+ static inline struct aws_byte_cursor aws_byte_cursor_from_array (const void * bytes , size_t len ) {
181
171
struct aws_byte_cursor cur ;
182
172
cur .ptr = (uint8_t * )bytes ;
183
173
cur .len = len ;
@@ -259,12 +249,9 @@ static inline size_t aws_nospec_index(size_t index, size_t bound) {
259
249
* Note that if len is above (SIZE_MAX / 2), this function will also treat it as
260
250
* a buffer overflow, and return NULL without changing *buf.
261
251
*/
262
- static inline struct aws_byte_cursor aws_byte_cursor_advance (
263
- struct aws_byte_cursor * cursor ,
264
- size_t len ) {
252
+ static inline struct aws_byte_cursor aws_byte_cursor_advance (struct aws_byte_cursor * cursor , size_t len ) {
265
253
struct aws_byte_cursor rv ;
266
- if (cursor -> len > (SIZE_MAX >> 1 ) || len > (SIZE_MAX >> 1 ) ||
267
- len > cursor -> len ) {
254
+ if (cursor -> len > (SIZE_MAX >> 1 ) || len > (SIZE_MAX >> 1 ) || len > cursor -> len ) {
268
255
rv .ptr = NULL ;
269
256
rv .len = 0 ;
270
257
} else {
@@ -288,13 +275,10 @@ static inline struct aws_byte_cursor aws_byte_cursor_advance(
288
275
* cursor->ptr points outside the true ptr length.
289
276
*/
290
277
291
- static inline struct aws_byte_cursor aws_byte_cursor_advance_nospec (
292
- struct aws_byte_cursor * cursor ,
293
- size_t len ) {
278
+ static inline struct aws_byte_cursor aws_byte_cursor_advance_nospec (struct aws_byte_cursor * cursor , size_t len ) {
294
279
struct aws_byte_cursor rv ;
295
280
296
- if (len <= cursor -> len && len <= (SIZE_MAX >> 1 ) &&
297
- cursor -> len <= (SIZE_MAX >> 1 )) {
281
+ if (len <= cursor -> len && len <= (SIZE_MAX >> 1 ) && cursor -> len <= (SIZE_MAX >> 1 )) {
298
282
/*
299
283
* Pass the length through aws_nospec_index. We do this after the
300
284
* branch, as otherwise we'd treat an out-of-bounds read as a
@@ -323,10 +307,7 @@ static inline struct aws_byte_cursor aws_byte_cursor_advance_nospec(
323
307
* If there is insufficient space in the cursor, returns false, leaving the
324
308
* cursor unchanged.
325
309
*/
326
- static inline bool aws_byte_cursor_read (
327
- struct aws_byte_cursor * AWS_RESTRICT cur ,
328
- void * AWS_RESTRICT dest ,
329
- size_t len ) {
310
+ static inline bool aws_byte_cursor_read (struct aws_byte_cursor * AWS_RESTRICT cur , void * AWS_RESTRICT dest , size_t len ) {
330
311
struct aws_byte_cursor slice = aws_byte_cursor_advance_nospec (cur , len );
331
312
332
313
if (slice .ptr ) {
@@ -360,9 +341,7 @@ static inline bool aws_byte_cursor_read_and_fill_buffer(
360
341
* If there is insufficient space in the cursor, returns false, leaving the
361
342
* cursor unchanged.
362
343
*/
363
- static inline bool aws_byte_cursor_read_u8 (
364
- struct aws_byte_cursor * AWS_RESTRICT cur ,
365
- uint8_t * AWS_RESTRICT var ) {
344
+ static inline bool aws_byte_cursor_read_u8 (struct aws_byte_cursor * AWS_RESTRICT cur , uint8_t * AWS_RESTRICT var ) {
366
345
return aws_byte_cursor_read (cur , var , 1 );
367
346
}
368
347
@@ -374,9 +353,7 @@ static inline bool aws_byte_cursor_read_u8(
374
353
* If there is insufficient space in the cursor, returns false, leaving the
375
354
* cursor unchanged.
376
355
*/
377
- static inline bool aws_byte_cursor_read_be16 (
378
- struct aws_byte_cursor * cur ,
379
- uint16_t * var ) {
356
+ static inline bool aws_byte_cursor_read_be16 (struct aws_byte_cursor * cur , uint16_t * var ) {
380
357
bool rv = aws_byte_cursor_read (cur , var , 2 );
381
358
382
359
if (AWS_LIKELY (rv )) {
@@ -394,9 +371,7 @@ static inline bool aws_byte_cursor_read_be16(
394
371
* If there is insufficient space in the cursor, returns false, leaving the
395
372
* cursor unchanged.
396
373
*/
397
- static inline bool aws_byte_cursor_read_be32 (
398
- struct aws_byte_cursor * cur ,
399
- uint32_t * var ) {
374
+ static inline bool aws_byte_cursor_read_be32 (struct aws_byte_cursor * cur , uint32_t * var ) {
400
375
bool rv = aws_byte_cursor_read (cur , var , 4 );
401
376
402
377
if (AWS_LIKELY (rv )) {
@@ -414,9 +389,7 @@ static inline bool aws_byte_cursor_read_be32(
414
389
* If there is insufficient space in the cursor, returns false, leaving the
415
390
* cursor unchanged.
416
391
*/
417
- static inline bool aws_byte_cursor_read_be64 (
418
- struct aws_byte_cursor * cur ,
419
- uint64_t * var ) {
392
+ static inline bool aws_byte_cursor_read_be64 (struct aws_byte_cursor * cur , uint64_t * var ) {
420
393
bool rv = aws_byte_cursor_read (cur , var , sizeof (* var ));
421
394
422
395
if (AWS_LIKELY (rv )) {
@@ -468,9 +441,7 @@ static inline bool aws_byte_cursor_write_from_whole_buffer(
468
441
* If there is insufficient space in the cursor, returns false, leaving the
469
442
cursor unchanged.
470
443
*/
471
- static inline bool aws_byte_cursor_write_u8 (
472
- struct aws_byte_cursor * AWS_RESTRICT cur ,
473
- uint8_t c ) {
444
+ static inline bool aws_byte_cursor_write_u8 (struct aws_byte_cursor * AWS_RESTRICT cur , uint8_t c ) {
474
445
return aws_byte_cursor_write (cur , & c , 1 );
475
446
}
476
447
@@ -481,9 +452,7 @@ static inline bool aws_byte_cursor_write_u8(
481
452
* If there is insufficient space in the cursor, returns false, leaving the
482
453
* cursor unchanged.
483
454
*/
484
- static inline bool aws_byte_cursor_write_be16 (
485
- struct aws_byte_cursor * cur ,
486
- uint16_t x ) {
455
+ static inline bool aws_byte_cursor_write_be16 (struct aws_byte_cursor * cur , uint16_t x ) {
487
456
x = aws_hton16 (x );
488
457
return aws_byte_cursor_write (cur , (uint8_t * )& x , 2 );
489
458
}
@@ -495,9 +464,7 @@ static inline bool aws_byte_cursor_write_be16(
495
464
* If there is insufficient space in the cursor, returns false, leaving the
496
465
* cursor unchanged.
497
466
*/
498
- static inline bool aws_byte_cursor_write_be32 (
499
- struct aws_byte_cursor * cur ,
500
- uint32_t x ) {
467
+ static inline bool aws_byte_cursor_write_be32 (struct aws_byte_cursor * cur , uint32_t x ) {
501
468
x = aws_hton32 (x );
502
469
return aws_byte_cursor_write (cur , (uint8_t * )& x , 4 );
503
470
}
@@ -509,9 +476,7 @@ static inline bool aws_byte_cursor_write_be32(
509
476
* If there is insufficient space in the cursor, returns false, leaving the
510
477
* cursor unchanged.
511
478
*/
512
- static inline bool aws_byte_cursor_write_be64 (
513
- struct aws_byte_cursor * cur ,
514
- uint64_t x ) {
479
+ static inline bool aws_byte_cursor_write_be64 (struct aws_byte_cursor * cur , uint64_t x ) {
515
480
x = aws_hton64 (x );
516
481
return aws_byte_cursor_write (cur , (uint8_t * )& x , 8 );
517
482
}
0 commit comments