ValidateStr
- Function
- August 22, 2025
Table of Contents
ValidateStr
ValidateStr
Description
Validate whether a given Str
object is valid. Not foolproof but will work most of the time. Aborts if provided Str
is not valid.
Parameters
Name | Direction | Description |
---|---|---|
s | in | Pointer to Str object to validate. |
Success
Continue execution, meaning given Str
object is most probably valid.
Failure
abort
Usage example (Cross-references)
- In
Io.c:781
:
}
ValidateStr(o);
ValidateStr(s);
- In
Io.c:782
:
ValidateStr(o);
ValidateStr(s);
// Store original length to calculate content size later
- In
Io.c:850
:
}
ValidateStr(o);
// Store original length to calculate content size later
- In
Io.c:1255
:
LOG_FATAL("Invalid arguments");
ValidateStr(s);
// Check for case conversion flags
- In
Io.c:2237
:
}
ValidateStr(o);
ValidateBitVec(bv);
- In
Str.c:20
:
Str* StrPrintf(Str* str, const char* fmt, ...) {
ValidateStr(str);
StrClear(str);
- In
Str.c:33
:
Str* StrAppendf(Str* str, const char* fmt, ...) {
ValidateStr(str);
va_list args;
- In
Str.c:44
:
static Str* string_va_printf(Str* str, const char* fmt, va_list args) {
ValidateStr(str);
va_list args_copy;
- In
Str.c:71
:
bool StrInitCopy(Str* dst, const Str* src) {
ValidateStr(src);
MemSet(dst, 0, sizeof(Str));
- In
Str.c:79
:
VecMergeR(dst, src);
ValidateStr(dst);
return true;
- In
Str.c:85
:
void StrDeinit(Str* copy) {
ValidateStr(copy);
if (copy->data) {
FREE(copy->data);
- In
Str.c:93
:
StrIters StrSplitToIters(Str* s, const char* key) {
ValidateStr(s);
StrIters sv = VecInit();
- In
Str.c:118
:
Strs StrSplit(Str* s, const char* key) {
ValidateStr(s);
Strs sv = VecInitWithDeepCopy(NULL, StrDeinit);
- In
Str.c:161
:
// = 1 means from right
Str strip_str(Str* s, const char* chars_to_strip, int split_direction) {
ValidateStr(s);
const char* strip_chars = chars_to_strip ? chars_to_strip : " \t\n\r\v\f";
- In
Str.c:194
:
bool StrStartsWithZstr(const Str* s, const char* prefix) {
ValidateStr(s);
return starts_with(s->data, s->length, prefix, ZstrLen(prefix));
}
- In
Str.c:199
:
bool StrEndsWithZstr(const Str* s, const char* suffix) {
ValidateStr(s);
return ends_with(s->data, s->length, suffix, ZstrLen(suffix));
}
- In
Str.c:204
:
bool StrStartsWithCstr(const Str* s, const char* prefix, size prefix_len) {
ValidateStr(s);
return starts_with(s->data, s->length, prefix, prefix_len);
}
- In
Str.c:209
:
bool StrEndsWithCstr(const Str* s, const char* suffix, size suffix_len) {
ValidateStr(s);
return ends_with(s->data, s->length, suffix, suffix_len);
}
- In
Str.c:214
:
bool StrStartsWith(const Str* s, const Str* prefix) {
ValidateStr(s);
return starts_with(s->data, s->length, prefix->data, prefix->length);
}
- In
Str.c:219
:
bool StrEndsWith(const Str* s, const Str* suffix) {
ValidateStr(s);
return ends_with(s->data, s->length, suffix->data, suffix->length);
}
- In
Str.c:226
:
static void
str_replace(Str* s, const char* match, size match_len, const char* replacement, size replacement_len, size count) {
ValidateStr(s);
size i = 0;
size replaced = 0;
- In
Str.c:243
:
void StrReplaceZstr(Str* s, const char* match, const char* replacement, size count) {
ValidateStr(s);
str_replace(s, match, ZstrLen(match), replacement, ZstrLen(replacement), count);
}
- In
Str.c:255
:
size count
) {
ValidateStr(s);
str_replace(s, match, match_len, replacement, replacement_len, count);
}
- In
Str.c:260
:
void StrReplace(Str* s, const Str* match, const Str* replacement, size count) {
ValidateStr(s);
str_replace(s, match->data, match->length, replacement->data, replacement->length, count);
}
- In
Str.c:329
:
Str* StrFromU64(Str* str, u64 value, const StrIntFormat* config) {
ValidateStr(str);
if (!config) {
- In
Str.c:376
:
Str* StrFromI64(Str* str, i64 value, const StrIntFormat* config) {
ValidateStr(str);
if (!config) {
- In
Str.c:410
:
Str* StrFromF64(Str* str, f64 value, const StrFloatFormat* config) {
ValidateStr(str);
if (!config) {
- In
Str.c:568
:
bool StrToU64(const Str* str, u64* value, const StrParseConfig* config) {
ValidateStr(str);
if (!value) {
- In
Str.c:658
:
bool StrToI64(const Str* str, i64* value, const StrParseConfig* config) {
ValidateStr(str);
if (!value) {
- In
Str.c:722
:
bool StrToF64(const Str* str, f64* value, const StrParseConfig* config) {
ValidateStr(str);
if (!value) {
- In
Str.c:861
:
}
void ValidateStr(const Str* s) {
return ValidateVec(s);
}
- In
Str.c:866
:
void ValidateStrs(const Strs* vs) {
VecForeachPtr(vs, sp, { ValidateStr(sp); });
}
- In
Str.Type.c:72
:
// Test ValidateStr macro
bool test_validate_str(void) {
printf("Testing ValidateStr macro\n");
// Create a valid Str
- In
Str.Type.c:78
:
// This should not crash
ValidateStr(&s);
// Note: We can't really test invalid strings here as ValidateStr
- In
Str.Type.c:111
:
// Deadend test: Test ValidateStr with invalid string (should crash/abort)
bool test_validate_invalid_str(void) {
printf("Testing ValidateStr with invalid string (should abort)\n");
// Create an invalid Str by corrupting its fields
- In
Str.Type.c:122
:
// This should abort the program
ValidateStr(&s);
// Should never reach here
- In
Str.Init.c:28
:
// Validate the string
ValidateStr(&s);
// Check that it's initialized correctly
- In
Str.Init.c:47
:
// Validate the string
ValidateStr(&s);
// Check that it's initialized correctly
- In
Str.Init.c:64
:
// Validate the string
ValidateStr(&s);
// Check that it's initialized correctly
- In
Str.Init.c:81
:
// Validate both strings
ValidateStr(&src);
ValidateStr(&dst);
- In
Str.Init.c:82
:
// Validate both strings
ValidateStr(&src);
ValidateStr(&dst);
// Check that dst is initialized correctly
- In
Str.Init.c:100
:
// Validate both strings
ValidateStr(&src);
ValidateStr(&dst);
- In
Str.Init.c:101
:
// Validate both strings
ValidateStr(&src);
ValidateStr(&dst);
// Check that dst is initialized correctly
- In
Str.Init.c:119
:
// Validate the string
ValidateStr(&s);
// Check that it's initialized correctly
- In
Str.Init.c:141
:
// Validate the string
ValidateStr(&stack_str);
// Check that it works correctly
- In
Str.Init.c:173
:
// Validate both strings
ValidateStr(&src);
ValidateStr(&dst);
- In
Str.Init.c:174
:
// Validate both strings
ValidateStr(&src);
ValidateStr(&dst);
// Check that the copy was successful
- In
Str.Init.c:191
:
// Validate the string before deinit
ValidateStr(&s);
// Deinit the string