aboutsummaryrefslogtreecommitdiff
path: root/lib/darwin/read.h
blob: 900d3d4b5ccb23ac6e4970ab31ebb18dbc12eeba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#pragma once
#include <string.h>
#include <stdint.h>
#include <stdbool.h>

bool read_leb128(void **ptr, void *end, bool is_signed, uint64_t *out);

static inline bool read_cstring(void **ptr, void *end, char **out) {
    char *s = *ptr;
    size_t maxlen = (char *) end - s;
    size_t len = strnlen(s, maxlen);
    if (len == maxlen)
        return false;
    *out = s;
    *ptr = s + len + 1;
    return true;
}