aboutsummaryrefslogtreecommitdiff
path: root/include/std
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-01-24 09:11:53 +0100
committerdec05eba <dec05eba@protonmail.com>2020-01-24 09:11:53 +0100
commit1dd53ce54c2008e3a11a636a496853cf6f9a5d65 (patch)
tree73f8ff8d048c8b1e4c6cf7acfd3e229650d044d5 /include/std
parent26f8fbc2c657ecffc874410691dd3fc83ba11131 (diff)
Convert hash map to gc, implement more instructions and call command
Diffstat (limited to 'include/std')
-rw-r--r--include/std/buffer.h9
-rw-r--r--include/std/hash_map.h25
-rw-r--r--include/std/string_view.h11
3 files changed, 7 insertions, 38 deletions
diff --git a/include/std/buffer.h b/include/std/buffer.h
index 3aad48b..7253d88 100644
--- a/include/std/buffer.h
+++ b/include/std/buffer.h
@@ -17,8 +17,13 @@ void tsl_buffer_init(TslBuffer *self);
void tsl_buffer_deinit(TslBuffer *self);
int tsl_buffer_append(TslBuffer *self, const void *data, size_t size);
-/* The buffer has to >= @size */
-void tsl_buffer_pop(TslBuffer *self, size_t size);
+/*
+ This function changes the size of the buffer without changing the capacity
+ and returns the value at the back of the buffer, which is valid until @tsl_buffer_append or
+ @tsl_buffer_deinit is called.
+ The buffer size has to be larger or equal to @size.
+*/
+void* tsl_buffer_pop(TslBuffer *self, size_t size);
void* tsl_buffer_begin(TslBuffer *self);
void* tsl_buffer_end(TslBuffer *self);
void tsl_buffer_move(TslBuffer *dst, TslBuffer *src);
diff --git a/include/std/hash_map.h b/include/std/hash_map.h
deleted file mode 100644
index b430d22..0000000
--- a/include/std/hash_map.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef TSL_HASH_MAP_H
-#define TSL_HASH_MAP_H
-
-#include "string_view.h"
-#include <stdint.h>
-
-typedef uint64_t (*TslHashFunc)(const void *data, size_t size);
-
-/* TODO: Optimize small hash map by using the members of the struct instead of allocating on heap */
-typedef struct {
- void *buckets_data; /* value=TslHashMapNode<void*>, data=|hash(uint64_t) + key_size(size_t) + key_data(...) data_size(size_t) + data_data(...)| */
- size_t buckets_size;
- size_t buckets_capacity;
-} TslHashMap;
-
-void tsl_hash_map_init(TslHashMap *self);
-void tsl_hash_map_deinit(TslHashMap *self);
-
-int tsl_hash_map_insert(TslHashMap *self, const TslStringView *key, const void *data, size_t size, TslHashFunc hash_func);
-/* Get a reference to the value by key @key, or NULL if it doesn't exist */
-void* tsl_hash_map_get(TslHashMap *self, const TslStringView *key, TslHashFunc hash_func);
-/* Get a reference to the value by key @key, or insert a new value for the key with a size of @size */
-int tsl_hash_map_get_or_create(TslHashMap *self, const TslStringView *key, size_t size, TslHashFunc hash_func, void **output);
-
-#endif /* TSL_HASH_MAP_H */
diff --git a/include/std/string_view.h b/include/std/string_view.h
deleted file mode 100644
index 4f9552a..0000000
--- a/include/std/string_view.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef TSL_STRING_VIEW_H
-#define TSL_STRING_VIEW_H
-
-#include <stddef.h>
-
-typedef struct {
- const char *data;
- size_t size;
-} TslStringView;
-
-#endif /* TSL_STRING_VIEW_H */