-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrange.h
37 lines (29 loc) · 834 Bytes
/
range.h
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
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 - 2022 TheVice
*
*/
#ifndef _RANGE_H_
#define _RANGE_H_
#include <stddef.h>
#include <stdint.h>
struct range
{
const uint8_t* start;
const uint8_t* finish;
};
ptrdiff_t range_size(const struct range* range);
uint8_t range_is_null_or_empty(const struct range* range);
uint8_t range_in_parts_is_null_or_empty(
const uint8_t* range_start, const uint8_t* range_finish);
uint8_t buffer_append_data_from_range(
void* storage, const struct range* data);
uint8_t buffer_append_range(
void* ranges, const struct range* data, ptrdiff_t data_count);
struct range* buffer_range_data(
const void* ranges, ptrdiff_t data_position);
#define BUFFER_TO_RANGE(R, B) \
(R).start = (const uint8_t*)buffer_uint8_t_data((B), 0);\
(R).finish = (R).start + buffer_size(B);
#endif