Skip to content

Commit

Permalink
rename vector_any implementation here is variant
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechsTech committed Dec 22, 2024
1 parent 1bbb169 commit e59a101
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ endif()

project(
raii
VERSION 1.3.0
VERSION 1.3.1
DESCRIPTION "An general RAII implementation for C, with Defer, simple high-level C11/C++11 like Threading/Futures, custom malloc/heap allocation."
HOMEPAGE_URL "https://zelang-dev.github.io/c-raii/"
LANGUAGES C
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ C_API args_t args_for(size_t, ...);

#define array(count, ...) args_for(count, __VA_ARGS__)
#define array_defer(arr) args_destructor_set(arr)
#define vectorize(vec) vectors_t vec = vector_any()
#define vectorize(vec) vectors_t vec = vector_variant()
#define vector(vec, count, ...) vectors_t vec = vector_for(nil, count, __VA_ARGS__)

#define $push_back(vec, value) vector_push_back(vec, (void_t)value)
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ C_API args_t args_for(size_t, ...);

#define array(count, ...) args_for(count, __VA_ARGS__)
#define array_defer(arr) args_destructor_set(arr)
#define vectorize(vec) vectors_t vec = vector_any()
#define vectorize(vec) vectors_t vec = vector_variant()
#define vector(vec, count, ...) vectors_t vec = vector_for(nil, count, __VA_ARGS__)

#define $push_back(vec, value) vector_push_back(vec, (void_t)value)
Expand Down
4 changes: 2 additions & 2 deletions include/raii.h
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ C_API u_string str_decode64_ex(memory_t *defer, u_string_t src);
C_API bool is_base64(u_string_t src);
C_API int strpos(const char *text, char *pattern);

C_API vectors_t vector_any(void);
C_API vectors_t vector_variant(void);
C_API vectors_t vector_for(vectors_t, size_t, ...);
C_API void vector_insert(vectors_t vec, int pos, void_t val);
C_API void vector_clear(vectors_t);
Expand Down Expand Up @@ -582,7 +582,7 @@ C_API values_type get_arg(void_t);

#define array(count, ...) args_for(count, __VA_ARGS__)
#define array_defer(arr) args_destructor_set(arr)
#define vectorize(vec) vectors_t vec = vector_any()
#define vectorize(vec) vectors_t vec = vector_variant()
#define vector(vec, count, ...) vectors_t vec = vector_for(nil, count, __VA_ARGS__)

#define $push_back(vec, value) vector_push_back(vec, (void_t)value)
Expand Down
4 changes: 2 additions & 2 deletions src/vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ vectors_t vector_for(vectors_t v, size_t item_count, ...) {
size_t i;

if (is_empty(v))
v = vector_any();
v = vector_variant();

if (item_count > 0) {
va_start(ap, item_count);
Expand All @@ -143,7 +143,7 @@ vectors_t vector_for(vectors_t v, size_t item_count, ...) {
return v;
}

RAII_INLINE vectors_t vector_any(void) {
RAII_INLINE vectors_t vector_variant(void) {
vectors_t vec = nullptr;
size_t cores = thrd_cpu_count();
vector_grow(vec, cores);
Expand Down
4 changes: 2 additions & 2 deletions tests/test-vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ TEST(vector_for) {
return 0;
}

TEST(vector_any) {
TEST(vector_variant) {
vectorize(v);

$push_back(v, strdup("hello"));
Expand All @@ -67,7 +67,7 @@ TEST(list) {
int result = 0;

EXEC_TEST(vector_for);
EXEC_TEST(vector_any);
EXEC_TEST(vector_variant);

return result;
}
Expand Down

0 comments on commit e59a101

Please sign in to comment.