aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDominik Maier <domenukk@gmail.com>2020-03-27 23:30:15 +0100
committerDominik Maier <domenukk@gmail.com>2020-04-01 13:10:05 +0200
commite71c2937de8a19cf9b3627b86894cafabcd45513 (patch)
tree1af4449f1a7a891e4c0aafc487be7c4bc9de7b5c /include
parent3d6c58df53bf2fecc068d1a4d48fbe4926d6257d (diff)
downloadafl++-e71c2937de8a19cf9b3627b86894cafabcd45513.tar.gz
code format
Diffstat (limited to 'include')
-rw-r--r--include/afl-fuzz.h17
-rw-r--r--include/alloc-inl.h13
2 files changed, 18 insertions, 12 deletions
diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h
index 2154d860..32eaf4af 100644
--- a/include/afl-fuzz.h
+++ b/include/afl-fuzz.h
@@ -583,27 +583,26 @@ typedef struct afl_state {
u8 clean_trace_custom[MAP_SIZE];
u8 first_trace[MAP_SIZE];
-/*needed for afl_fuzz_one */
-// TODO: see which we can reuse
- u8 *out_buf;
+ /*needed for afl_fuzz_one */
+ // TODO: see which we can reuse
+ u8 * out_buf;
size_t out_size;
- u8 *out_scratch_buf;
+ u8 * out_scratch_buf;
size_t out_scratch_size;
- u8 *eff_buf;
+ u8 * eff_buf;
size_t eff_size;
- u8 *in_buf;
+ u8 * in_buf;
size_t in_size;
- u8 *in_scratch_buf;
+ u8 * in_scratch_buf;
size_t in_scratch_size;
- u8 *ex_buf;
+ u8 * ex_buf;
size_t ex_size;
-
} afl_state_t;
/* A global pointer to all instances is needed (for now) for signals to arrive
diff --git a/include/alloc-inl.h b/include/alloc-inl.h
index 75b038c1..92d29c1e 100644
--- a/include/alloc-inl.h
+++ b/include/alloc-inl.h
@@ -774,7 +774,8 @@ static inline void TRK_ck_free(void *ptr, const char *file, const char *func,
Will FATAL if size_needed is <1 or *size is negative.
@return For convenience, this function returns *buf.
*/
-static inline void *ck_maybe_grow(void **buf, size_t *size, size_t size_needed) {
+static inline void *ck_maybe_grow(void **buf, size_t *size,
+ size_t size_needed) {
/* Oops. found a bug? */
if (unlikely(size_needed < 1)) FATAL("cannot grow to non-positive size");
@@ -785,21 +786,27 @@ static inline void *ck_maybe_grow(void **buf, size_t *size, size_t size_needed)
/* No inital size was set */
if (*size == 0) *size = INITIAL_GROWTH_SIZE;
while (*size < size_needed) {
+
*size *= 2;
+
}
+
*buf = ck_realloc(*buf, *size);
return *buf;
}
/* Swaps buf1 ptr and buf2 ptr, as well as their sizes */
-static inline void swap_bufs(void **buf1, size_t *size1, void **buf2, size_t *size2) {
- void *scratch_buf = *buf1;
+static inline void swap_bufs(void **buf1, size_t *size1, void **buf2,
+ size_t *size2) {
+
+ void * scratch_buf = *buf1;
size_t scratch_size = *size1;
*buf1 = *buf2;
*size1 = *size2;
*buf2 = scratch_buf;
*size2 = scratch_size;
+
}
#undef INITIAL_GROWTH_SIZE