some progress on scanner. begin clusterfuck map
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
#include "cig.h"
|
||||
#include <assert.h>
|
||||
|
||||
#define FREE (-1)
|
||||
#define GRAVESTONE (-2)
|
||||
|
||||
static inline int mapping_cap(int capacity) {
|
||||
return capacity * 2;
|
||||
}
|
||||
@@ -58,21 +61,27 @@ void *map_create_func(
|
||||
|
||||
void *map_grow_func(void *this, const char *file, int line) {
|
||||
map_header_t *header = PTR_FROM_FIELD_PTR(map_header_t, bytes, this);
|
||||
allocator_t allocator = header->allocator;
|
||||
int new_capacity = 1;
|
||||
if (header->capacity > 0) {
|
||||
new_capacity = header->capacity * 2;
|
||||
}
|
||||
internal_map_sizes_t new_size = internal_map_sizes(
|
||||
new_capacity,
|
||||
header->itemsize
|
||||
);
|
||||
header = allocator_resize_func(allocator, header, new_size.bytes, file, line);
|
||||
// TODO!!! Overwrite the mapping arr with -1, then iterate through the
|
||||
// items arr and find the hashes of the values to populate the mappings
|
||||
// arr.
|
||||
assert(false && "TODO");
|
||||
int new_size = header->n_items + 1;
|
||||
|
||||
if (header->capacity < new_size) {
|
||||
allocator_t allocator = header->allocator;
|
||||
int new_capacity = 1;
|
||||
if (header->capacity > 0) {
|
||||
new_capacity = header->capacity * 2;
|
||||
}
|
||||
internal_map_sizes_t new_size = internal_map_sizes(
|
||||
new_capacity,
|
||||
header->itemsize
|
||||
);
|
||||
header = allocator_resize_func(allocator, header, new_size.bytes, file, line);
|
||||
// TODO!!! Overwrite the mapping arr with -1, then iterate through the
|
||||
// items arr and find the hashes of the values to populate the mappings
|
||||
// arr.
|
||||
assert(false && "TODO");
|
||||
TODO
|
||||
}
|
||||
|
||||
header->n_items = new_size;
|
||||
return header->bytes;
|
||||
}
|
||||
|
||||
@@ -91,3 +100,7 @@ int map_cap(void *this) {
|
||||
map_header_t *header = PTR_FROM_FIELD_PTR(map_header_t, bytes, this);
|
||||
return header->capacity;
|
||||
}
|
||||
|
||||
#undef FREE
|
||||
#undef GRAVESTONE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user