summaryrefslogtreecommitdiff
path: root/src/til_str.c
AgeCommit message (Collapse)Author
2023-08-14til_str: handle overflows in til_str_appendf()Vito Caputo
In the wholesale transition to til_module_setup_full() there's been a lot more problematic randomized setups either extremely deep or plain infinite. Due to the primitive escaping mechanism performed by til_settings_as_arg(), where escape patterns grow exponentially with depth, it's quite realistic (and observed) for these problematic setups to exceed SIZE_MAX. So I'm putting some guard rails in to cap a given til_str_t to SIZE_MAX. It might make more sense to move the limit well below SIZE_MAX, but this should at least prevent overflows.
2023-08-14til_str: realloc in increasingly larger incrementsVito Caputo
Typically people do a exponential style growth in such circumstances, but in my experience that tends to allocate nearly double what's needed quite often. Trying just a linearly increasing allocation size that bumps up the minimum amount every time a resize is triggered. If the needed amount exceeds the new growth increment, the larger value is used, but the growth rate still follows the minimum bump. I expect this to evolve more, just wanted to do something to speed up til_str a bit from it's naive approach.
2023-07-04til_str: mechanical rename s/seed/string/Vito Caputo
I get why I called this seed at the time as it was the starting string of a potentially larger buildup... but it's just ambiguous naming with the other more descriptive uses of seed in the tree, and isn't even really appropriate.
2023-07-04til_str: exclude \0 from res_len for til_str_buf()/til_str_to_buf()Vito Caputo
It's more ergonomic more often to behave consistently with strlen() here, plus it's just the established mental model. While here I made til_settings_path_as_buf() private as nothing external uses it, it's essentially just a logically distinct private helper function from the public wrappers around it. Dragged into this changeset due to clarifying some naming/semantics as it's one of the few til_str_to_buf() callers. But nobody was actually passing a non-NULL res_bufsz/res_len to it anyways, as its use is minimal.
2023-07-04til_str: introduce til_str_chomp()Vito Caputo
Helper for trimming off a trailing CRNL or NL if present Clearly I once knew perl if this is the name that came to mind
2023-07-04til_str: fix va_start/va_end usage in til_str_newf()Vito Caputo
You can't just reuse the ap in multiple calls to vsnprintf without restarting... fixed in the obvious way
2023-06-12til_str: add preliminary growable string typeVito Caputo
Preparation for eliminating open_memstream() usage...
© All Rights Reserved