summaryrefslogtreecommitdiffstats
path: root/src/util/Makefile.sources
diff options
context:
space:
mode:
authorThomas Helland <[email protected]>2017-05-15 21:36:52 +0200
committerThomas Helland <[email protected]>2017-09-26 18:24:33 +0200
commit7885bb684d8a1ee9fbdcf85603e1f923a3526b22 (patch)
tree3c9ec8598cf6948b60c557b2b1b6447bcc466855 /src/util/Makefile.sources
parent379b24a40d3d34ffdaaeb1b328f50e28ecb01468 (diff)
util: Add a string buffer implementation
Based on Vladislav Egorovs work on the preprocessor, but split out to a util functionality that should be universal. Setup, teardown, memory handling and general layout is modeled around the hash_table and the set, to make it familiar for everyone. A notable change is that this implementation is always null terminated. The rationale is that it will be less error-prone, as one might access the buffer directly, thereby reading a non-terminated string. Also, vsnprintf and friends prints the null-terminator. Signed-off-by: Thomas Helland <[email protected]> Tested-by: Dieter Nützel <Dieter at nuetzel-hh.de> Reviewed-by: Nicolai Hähnle <[email protected]> V2: Address review feedback from Timothy and Grazvydas - Fix MINGW preprocessor check - Changed len from uint to int - Make string argument const in append function - Move to header and inline append function - Add crimp_to_fit function for resizing buffer V3: Move include of ralloc to string_buffer.h V4: Use u_string.h for a cross-platform working vsnprintf V5: Remember to cast to char * in crimp function V6: Address review feedback from Nicolai - Handle !str->buf in buffer_create - Ensure va_end is always called in buffer_append_all - Add overflow check in buffer_append_len - Do not expose buffer_space_left, just remove it - Clarify why a loop is used in vprintf, change to for-loop - Add a va_copy to buffer_vprintf to fix failure to append arguments when having to resize the buffer for vsnprintf. V7: Address more review feedback from Nicolai - Add missing va_end corresponding to va_copy - Error check failure to allocate in crimp_to_fit
Diffstat (limited to 'src/util/Makefile.sources')
-rw-r--r--src/util/Makefile.sources2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/util/Makefile.sources b/src/util/Makefile.sources
index 4ed4e39f039..c7f6516a992 100644
--- a/src/util/Makefile.sources
+++ b/src/util/Makefile.sources
@@ -37,6 +37,8 @@ MESA_UTIL_FILES := \
simple_list.h \
slab.c \
slab.h \
+ string_buffer.c \
+ string_buffer.h \
strndup.h \
strtod.c \
strtod.h \