This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Description
Which might not be what the user actually want.
Consider this use case.
Cstr_Array line = cstr_array_make(cxx, CFLAGS_EXE, NULL);
FOREACH_FILE_IN_DIR(file, ".",
{
if (ENDS_WITH(file, ".o"))
{
line = cstr_array_append(line, file);
}
});
Cmd cmd = {
.line = line
};
cmd_run_sync(cmd);
Here we actually need to strdup the string before pushing it to the list:
--- test.c 2021-07-30 03:22:06.603302201 +0700
+++ test2.c 2021-07-30 03:22:22.127512662 +0700
@@ -2,7 +2,7 @@
FOREACH_FILE_IN_DIR(file, ".", {
if (ENDS_WITH(file, ".o"))
{
- line = cstr_array_append(line, file);
+ line = cstr_array_append(line, strdup(file));
}
});
Cmd cmd = {
We need to think how we wanna approach this usability issue. Maybe do that strdup for the user?
(Found by @Ciremun)