dynamic string implemented
MMakefile
@@ -1,3 +1,3 @@
all:
gcc -Og -g -march=native -shared -fPIC -fstrict-aliasing vector.c -o cutils.so -flto \
gcc -Og -g -march=native -shared -fPIC -fstrict-aliasing vector.c dyn_string.c -o cutils.so -flto \
-Wall -Werror -Wpedantic -Wnull-dereference -Wshadow -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wcast-qual -Wstrict-overflow=5 -Wunreachable-code -Wno-unused-parameter
Mcutils.h
@@ -1,4 +1,5 @@
#ifndef CUTILS_H
#define CUTILS_H
#include <vector.h>
#include <dyn_string.h>
#endif //CUTILS_H
Mvector.c
@@ -12,7 +12,7 @@ Vector* new_vector(void)
return NULL;
}
vector->length = 0;
vector->capacity = 4;
vector->capacity = VECTOR_DEFAULT_SIZE;
return vector;
}
@@ -84,7 +84,7 @@ FindReturn vector_find(const Vector* haystack, const void* needle, bool (*cmp)(c
bool vector_insert(Vector* vector, size_t index, void* item)
{
if(!vector_adjust_size(vector, ++vector->length))
if(!vector_adjust_size(vector, vector->length))
return false;
memmove(vector->items+index+1, vector->items+index, (vector->length-index)*sizeof(*vector->items));