aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorGavin Howard <gavin@yzena.com>2021-06-29 22:34:27 -0600
committerGavin Howard <gavin@yzena.com>2021-06-29 22:37:07 -0600
commit78b97db01180b0cd07a05345f48732c023540dba (patch)
tree6d2bbfd5ce73f3bfe538f0d75263b048874a34f7 /include
parent968354ba9a8fa7777d02914cdd2918fa97efe471 (diff)
downloadplatform_external_bc-78b97db01180b0cd07a05345f48732c023540dba.tar.gz
platform_external_bc-78b97db01180b0cd07a05345f48732c023540dba.tar.bz2
platform_external_bc-78b97db01180b0cd07a05345f48732c023540dba.zip
Improve slabs
This commit does a lot. First, it makes sure that dc works with the slabs, even though it cleans with them now (I forgot that when I introduced slabs). Second, I removed a place where I used the vm slabs for the bc parser and made it use a special slab in the parser itself. Then, I made slab vector code to do the handling, in order to remove problems. I still expect that AFL++ will find crashes, though... Signed-off-by: Gavin Howard <gavin@yzena.com>
Diffstat (limited to 'include')
-rw-r--r--include/parse.h2
-rw-r--r--include/vector.h35
-rw-r--r--include/vm.h3
3 files changed, 24 insertions, 16 deletions
diff --git a/include/parse.h b/include/parse.h
index 880162a3..2d4173fc 100644
--- a/include/parse.h
+++ b/include/parse.h
@@ -146,6 +146,8 @@ typedef struct BcParse {
/// overwrite the string stored in the lexer. This buffer is for copying
/// that string from the lexer to keep it safe.
BcVec buf;
+
+ BcVec slab;
#endif // BC_ENABLED
/// A reference to the program to grab the current function when necessary.
diff --git a/include/vector.h b/include/vector.h
index a9dd7c0b..79422c9c 100644
--- a/include/vector.h
+++ b/include/vector.h
@@ -49,21 +49,6 @@ typedef unsigned char uchar;
typedef void (*BcVecFree)(void*);
-#define BC_SLAB_SIZE (4096)
-
-typedef struct BcSlab {
- char *s;
- size_t len;
-} BcSlab;
-
-void bc_slab_init(BcSlab *s);
-
-char* bc_slab_add(BcSlab *s, const char *str, size_t len);
-void bc_slab_clear(BcSlab *s);
-void bc_slab_undo(BcSlab *s, size_t len);
-
-void bc_slab_free(void *slab);
-
// Forward declaration.
struct BcId;
@@ -144,4 +129,24 @@ char* bc_map_name(const BcVec *restrict v, size_t idx);
extern const BcVecFree bc_vec_dtors[];
+#if !BC_ENABLE_LIBRARY
+
+#define BC_SLAB_SIZE (4096)
+
+typedef struct BcSlab {
+ char *s;
+ size_t len;
+} BcSlab;
+
+void bc_slab_free(void *slab);
+
+void bc_slabvec_init(BcVec* v);
+char* bc_slabvec_strdup(BcVec *v, const char *str);
+void bc_slabvec_undo(BcVec *v, size_t len);
+void bc_slabvec_clear(BcVec *v);
+
+#define bc_slabvec_free bc_vec_free
+
+#endif // !BC_ENABLE_LIBRARY
+
#endif // BC_VECTOR_H
diff --git a/include/vm.h b/include/vm.h
index 2c6ee6a5..8bf82d5e 100644
--- a/include/vm.h
+++ b/include/vm.h
@@ -306,7 +306,9 @@ typedef struct BcVm {
BcVec main_const_slab;
BcVec main_slabs;
+#if BC_ENABLED
BcVec other_slabs;
+#endif // BC_ENABLED
#endif // !BC_ENABLE_LIBRARY
#if BC_DEBUG_CODE
@@ -334,7 +336,6 @@ size_t bc_vm_growSize(size_t a, size_t b);
void* bc_vm_malloc(size_t n);
void* bc_vm_realloc(void *ptr, size_t n);
char* bc_vm_strdup(const char *str);
-char* bc_vm_strdup2(const char *str, BcVec *slabs);
bool bc_vm_readLine(bool clear);