diff options
author | comex | 2015-01-20 21:48:38 -0500 |
---|---|---|
committer | comex | 2015-01-20 21:58:52 -0500 |
commit | c2728b5b3416d3bb2dedb62366a8e87e05d8629a (patch) | |
tree | 2b9bc6f8c365237ceeac980498d6b24df80b6fa3 /lib/darwin/read.h | |
parent | revert THAT WHOLE THING because we can't actually use it for inject (diff) | |
download | substitute-c2728b5b3416d3bb2dedb62366a8e87e05d8629a.tar.gz |
...
Diffstat (limited to 'lib/darwin/read.h')
-rw-r--r-- | lib/darwin/read.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/darwin/read.h b/lib/darwin/read.h new file mode 100644 index 0000000..900d3d4 --- /dev/null +++ b/lib/darwin/read.h @@ -0,0 +1,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; +} + |