VecPushBack
Description
Append a single element to the end of the vector, taking ownership of val when no deep-copy handler is configured. Default unsuffixed form aliasing to the L (ownership) variant; expands through VecInsert at index length. See VecPushBackL for the full SUCCESS/FAILURE contract.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
ArgParse.c:453:
sp.target = target.target;
sp.seen = false;
VecPushBack(&self->specs, sp);
}- In
ArgParse.c:643:
help.kind = ARG_KIND_BOOL;
help.target = NULL;
VecPushBack(&self->specs, help);
}- In
Debug.c:373:
entry.free_trace_n = (u32)CaptureStackTrace(entry.free_trace, depth, 3);
}
VecPushBack(&self->freed, entry);
}- In
Str.c:266:
if (next) {
StrIter si = {.data = (char *)prev, .length = next - prev, .pos = 0, .alignment = 1};
VecPushBack(&sv, si);
prev = next + keylen;
} else {- In
Str.c:270:
} else {
StrIter si = {.data = (char *)prev, .length = end - prev, .pos = 0, .alignment = 1};
VecPushBack(&sv, si);
break;
}- In
Str.c:302:
if (next) {
Str tmp = StrInitFromCstr(prev, next - prev, s->allocator);
VecPushBack(&sv, tmp);
prev = next + keylen;
} else {- In
Str.c:307:
if (ZstrCompareN(prev, key, end - prev)) {
Str tmp = StrInitFromCstr(prev, end - prev, s->allocator);
VecPushBack(&sv, tmp);
}
break;- In
Dir.c:115:
direntry.name = StrInitFromCstr(findFileData.cFileName, ZstrLen(findFileData.cFileName), alloc);
VecPushBack(&dc, direntry);
} while (FindNextFile(hFind, &findFileData) != 0);
}- In
Dir.c:267:
direntry.type = dirent_type_to_misra(de->d_type);
direntry.name = StrInitFromCstr(nm, name_len, alloc);
VecPushBack(&dc, direntry);
}
off += de->d_reclen;- In
VecCharPtr.c:59:
char *str = generate_cstring(data, offset, data_size, 32);
if (str) {
VecPushBack(vec, str);
cleanup_cstring(str);
}- In
VecCharPtr.c:411:
char *str = generate_cstring(data, offset, data_size, 16);
if (str) {
VecPushBack(&temp, str);
cleanup_cstring(str);
}- In
VecCharPtr.c:480:
char *str = generate_cstring(data, offset, data_size, 16);
if (str) {
VecPushBack(&temp, str);
cleanup_cstring(str);
}- In
VecStr.c:89:
case VEC_STR_PUSH_BACK : {
Str str = generate_str_from_input(data, offset, data_size, 32, alloc);
VecPushBack(vec, str);
break;
}- In
VecStr.c:396:
for (size_t i = 0; i < count; i++) {
Str str = generate_str_from_input(data, offset, data_size, 16, alloc);
VecPushBack(&temp, str);
}- In
VecStr.c:459:
for (size_t i = 0; i < count; i++) {
Str str = generate_str_from_input(data, offset, data_size, 16, alloc);
VecPushBack(&temp, str);
StrDeinit(&str);
}- In
VecInt.c:38:
case VEC_INT_PUSH_BACK : {
i32 value = (i32)extract_u32(data, offset, data_size);
VecPushBack(vec, value);
break;
}- In
VecInt.c:340:
for (uint8_t i = 0; i < count && *offset + 4 <= data_size; i++) {
i32 value = (i32)extract_u32(data, offset, data_size);
VecPushBack(&temp, value);
}- In
VecInt.c:394:
for (uint8_t i = 0; i < count && *offset + 4 <= data_size; i++) {
i32 value = (i32)extract_u32(data, offset, data_size);
VecPushBack(&temp, value);
} i32 value = 0;
JR_INT(si1, value);
VecPushBack(&items, value);
});
}); Str value = StrInit(&alloc);
JR_STR(si2, value);
VecPushBack(&data, value);
});
}); i32 item = 0;
JR_INT(si, item);
VecPushBack(&obj.filled_items, item);
});
}); sym.binary_id = 888;
sym.debug = true;
VecPushBack(&response.data, sym);
JW_OBJ(json, { FunctionInfo func1 = {12345, StrInitFromZstr("test_func", &alloc), 1024, 4096};
FunctionInfo func2 = {54321, StrInitFromZstr("helper_func", &alloc), 512, 8192};
VecPushBack(&functions, func1);
VecPushBack(&functions, func2); FunctionInfo func2 = {54321, StrInitFromZstr("helper_func", &alloc), 512, 8192};
VecPushBack(&functions, func1);
VecPushBack(&functions, func2);
JW_OBJ(json, { Str tag2 = StrInitFromZstr("x86", &alloc);
VecPushBack(&result.tags, tag1);
VecPushBack(&result.tags, tag2);
VecPushBack(&result.tags, tag1);
VecPushBack(&result.tags, tag2);
result.created_at = StrInitFromZstr("2024-04-01", &alloc); sym1.target_function_id = 222;
sym1.distance = 0.9;
VecPushBack(&symbols, sym1);
AnnSymbol sym2 = {0}; sym2.target_function_id = 444;
sym2.distance = 0.8;
VecPushBack(&symbols, sym2);
JW_OBJ(json, { Vec(u32) numbers = VecInit(&alloc);
u32 num1 = 1, num2 = 2, num3 = 3;
VecPushBack(&numbers, num1);
VecPushBack(&numbers, num2);
VecPushBack(&numbers, num3); u32 num1 = 1, num2 = 2, num3 = 3;
VecPushBack(&numbers, num1);
VecPushBack(&numbers, num2);
VecPushBack(&numbers, num3); VecPushBack(&numbers, num1);
VecPushBack(&numbers, num2);
VecPushBack(&numbers, num3);
Vec(Str) strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc); Str str3 = StrInitFromZstr("c", &alloc);
VecPushBack(&strings, str1);
VecPushBack(&strings, str2);
VecPushBack(&strings, str3);
VecPushBack(&strings, str1);
VecPushBack(&strings, str2);
VecPushBack(&strings, str3); VecPushBack(&strings, str1);
VecPushBack(&strings, str2);
VecPushBack(&strings, str3);
Vec(bool) booleans = VecInit(&alloc); Vec(bool) booleans = VecInit(&alloc);
bool bool1 = true, bool2 = false, bool3 = true;
VecPushBack(&booleans, bool1);
VecPushBack(&booleans, bool2);
VecPushBack(&booleans, bool3); bool bool1 = true, bool2 = false, bool3 = true;
VecPushBack(&booleans, bool1);
VecPushBack(&booleans, bool2);
VecPushBack(&booleans, bool3); VecPushBack(&booleans, bool1);
VecPushBack(&booleans, bool2);
VecPushBack(&booleans, bool3);
JW_OBJ(json, { Str lang3 = StrInitFromZstr("Rust", &alloc);
VecPushBack(&languages, lang1);
VecPushBack(&languages, lang2);
VecPushBack(&languages, lang3);
VecPushBack(&languages, lang1);
VecPushBack(&languages, lang2);
VecPushBack(&languages, lang3); VecPushBack(&languages, lang1);
VecPushBack(&languages, lang2);
VecPushBack(&languages, lang3);
JW_OBJ(json, { JW_ARR_KV(json, "languages", languages, lang, { JW_STR(json, lang); }); }); Str tag3 = StrInitFromZstr("portable", &alloc);
VecPushBack(&product.tags, tag1);
VecPushBack(&product.tags, tag2);
VecPushBack(&product.tags, tag3);
VecPushBack(&product.tags, tag1);
VecPushBack(&product.tags, tag2);
VecPushBack(&product.tags, tag3); VecPushBack(&product.tags, tag1);
VecPushBack(&product.tags, tag2);
VecPushBack(&product.tags, tag3);
JW_OBJ(json, { Vec(i32) filled_arr = VecInit(&alloc);
i32 val1 = 1, val2 = 2;
VecPushBack(&filled_arr, val1);
VecPushBack(&filled_arr, val2); i32 val1 = 1, val2 = 2;
VecPushBack(&filled_arr, val1);
VecPushBack(&filled_arr, val2);
i32 x_value = 1; });
VecPushBack(&symbols, sym);
});
}); });
VecPushBack(&response.data, sym);
});
}); );
VecPushBack(&response.data, sym);
WriteFmt("[DEBUG] Added symbol to vector, length now: {}\n", VecLen(&response.data));
}); );
VecPushBack(&response.data, sym);
WriteFmt("[DEBUG] Added symbol to vector, length now: {}\n", VecLen(&response.data));
}); Str lang = StrInit(&alloc);
JR_STR(si, lang);
VecPushBack(&languages, lang);
});
}); Str tag = StrInit(&alloc);
JR_STR(si, tag);
VecPushBack(&product.tags, tag);
});
});- In
RoundTrip.c:376:
i32 nums[5] = {1, 2, 3, -5, 0};
for (size i = 0; i < 5; i++) {
VecPushBack(&original_numbers, nums[i]);
}- In
RoundTrip.c:385:
Str str4 = StrInitFromZstr("last", &alloc);
VecPushBack(&original_strings, str1);
VecPushBack(&original_strings, str2);
VecPushBack(&original_strings, str3);- In
RoundTrip.c:386:
VecPushBack(&original_strings, str1);
VecPushBack(&original_strings, str2);
VecPushBack(&original_strings, str3);
VecPushBack(&original_strings, str4);- In
RoundTrip.c:387:
VecPushBack(&original_strings, str1);
VecPushBack(&original_strings, str2);
VecPushBack(&original_strings, str3);
VecPushBack(&original_strings, str4);- In
RoundTrip.c:388:
VecPushBack(&original_strings, str2);
VecPushBack(&original_strings, str3);
VecPushBack(&original_strings, str4);
// Write to JSON
- In
RoundTrip.c:406:
i32 num = 0;
JR_INT(si, num);
VecPushBack(&parsed_numbers, num);
});
JR_ARR_KV(si, "strings", {- In
RoundTrip.c:411:
Str str = StrInit(&alloc);
JR_STR(si, str);
VecPushBack(&parsed_strings, str);
});
});- In
RoundTrip.c:545:
Str feature2 = StrInitFromZstr("logging", &alloc);
VecPushBack(&original.config.features, feature1);
VecPushBack(&original.config.features, feature2);- In
RoundTrip.c:546:
VecPushBack(&original.config.features, feature1);
VecPushBack(&original.config.features, feature2);
original.numbers = VecInitT(original.numbers, &alloc);- In
RoundTrip.c:551:
i32 vals[3] = {10, 20, -5};
for (size i = 0; i < 3; i++) {
VecPushBack(&original.numbers, vals[i]);
}- In
RoundTrip.c:557:
bool bools[3] = {true, false, true};
for (size i = 0; i < 3; i++) {
VecPushBack(&original.flags, bools[i]);
}- In
RoundTrip.c:608:
Str feature = StrInit(&alloc);
JR_STR(si, feature);
VecPushBack(&parsed.config.features, feature);
});
});- In
RoundTrip.c:614:
i32 num = 0;
JR_INT(si, num);
VecPushBack(&parsed.numbers, num);
});
JR_ARR_KV(si, "flags", {- In
RoundTrip.c:619:
bool flag = false;
JR_BOOL(si, flag);
VecPushBack(&parsed.flags, flag);
});
});- In
RoundTrip.c:706:
i32 num = 0;
JR_INT(si, num);
VecPushBack(&parsed_numbers, num);
});
JR_ARR_KV(si, "empty_strings", {- In
RoundTrip.c:711:
Str str = StrInit(&alloc);
JR_STR(si, str);
VecPushBack(&parsed_strings, str);
});
JR_OBJ_KV(si, "empty_object", { found_empty_object = true; });- In
Vec.Remove.c:41:
for (int i = 0; i < 5; i++) {
int val = values[i];
VecPushBack(&vec, val);
}- In
Vec.Remove.c:89:
for (int i = 0; i < 5; i++) {
int val = values[i];
VecPushBack(&vec, val);
}- In
Vec.Remove.c:137:
for (int i = 0; i < 5; i++) {
int val = values[i];
VecPushBack(&vec, val);
}- In
Vec.Remove.c:185:
for (int i = 0; i < 5; i++) {
int val = values[i];
VecPushBack(&vec, val);
}- In
Vec.Remove.c:222:
for (int i = 0; i < 7; i++) {
int val = values[i];
VecPushBack(&vec, val);
}- In
Vec.Remove.c:257:
for (int i = 0; i < 10; i++) {
int val = i * 10;
VecPushBack(&vec, val);
}- In
Vec.Remove.c:334:
for (int i = 0; i < 5; i++) {
int val = values[i];
VecPushBack(&vec, val);
}- In
Vec.Remove.c:379:
int values[] = {10, 20, 30, 40, 50};
for (int i = 0; i < 5; i++) {
VecPushBack(&vec, values[i]);
}- In
Vec.Remove.c:415:
int values[] = {10, 20, 30, 40, 50};
for (int i = 0; i < 5; i++) {
VecPushBack(&vec, values[i]);
}- In
Vec.Remove.c:450:
int values[] = {10, 20, 30, 40, 50};
for (int i = 0; i < 5; i++) {
VecPushBack(&vec, values[i]);
}- In
Vec.Remove.c:531:
int values[] = {10, 20, 30, 40, 50};
for (int i = 0; i < 5; i++) {
VecPushBack(&vec, values[i]);
}- In
Vec.Remove.c:608:
int values[] = {10, 20, 30, 40, 50, 60, 70};
for (int i = 0; i < 7; i++) {
VecPushBack(&vec, values[i]);
}- In
Vec.Remove.c:645:
int values[] = {10, 20, 30, 40, 50, 60, 70};
for (int i = 0; i < 7; i++) {
VecPushBack(&vec, values[i]);
}- In
Vec.Remove.c:680:
int values[] = {10, 20, 30, 40, 50, 60, 70};
for (int i = 0; i < 7; i++) {
VecPushBack(&vec, values[i]);
}- In
Vec.Remove.c:759:
int values[] = {10, 20, 30, 40, 50, 60, 70};
for (int i = 0; i < 7; i++) {
VecPushBack(&vec, values[i]);
}- In
Str.Type.c:56:
Str s2 = StrInitFromZstr("World", &alloc);
VecPushBack(&sv, s1);
VecPushBack(&sv, s2);- In
Str.Type.c:57:
VecPushBack(&sv, s1);
VecPushBack(&sv, s2);
// Check that it behaves like a Vec of Str objects
- In
Vec.Insert.c:27:
bool test_vec_push_back(void) {
WriteFmt("Testing VecPushBack\n");
// Create a vector of integers
- In
Insert.h:1003:
#define VecMustPushBack(v, val) \
do { \
if (!VecPushBack((v), (val))) { \
LOG_FATAL("VecMustPushBack failed"); \
} \
Last updated on