mesa/src/util
Thomas Helland 7885bb684d 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 <thomashelland90@gmail.com>
Tested-by: Dieter Nützel <Dieter at nuetzel-hh.de>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>

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
2017-09-26 18:24:33 +02:00
..
sha1 util/sha1: add non-typedef name for the SHA1_CTX struct 2017-03-15 11:15:53 +00:00
tests/hash_table mesa: Add .gitignore entries for make check binaries 2016-05-25 09:41:44 -07:00
xmlpool radeonsi: allow out-of-order rasterization in commutative blending cases 2017-09-18 11:25:20 +02:00
.gitignore mesa: Add .gitignore entries for make check binaries 2016-05-25 09:41:44 -07:00
Android.mk android: export intermediates from libmesa_util 2017-08-02 10:32:48 +03:00
bitscan.c util/bitscan: use correct signature for ffs/ffsll 2017-03-13 11:16:34 +00:00
bitscan.h gallium: use "ull" number suffix to keep the QtCreator parser happy 2017-07-10 22:44:48 +02:00
bitset.h util/bitset: Allow iterating over const bitsets 2016-03-24 15:20:44 -07:00
build_id.c util/build_id: Include <dlfcn.h> 2017-09-13 12:43:42 -07:00
build_id.h util: Query build-id by symbol address, not library name 2017-09-13 09:49:27 -07:00
crc32.c util: import CRC32 implementation from gallium 2016-11-22 18:05:51 +01:00
crc32.h util: import CRC32 implementation from gallium 2016-11-22 18:05:51 +01:00
debug.c util: move brw_env_var_as_boolean() to util 2015-11-24 10:02:55 -05:00
debug.h util: rename include guard to avoid clash 2017-09-07 08:54:44 +01:00
disk_cache.c util/disk_cache: turn MESA_GLSL_CACHE_DISABLE into a boolean 2017-09-12 13:53:12 +01:00
disk_cache.h glsl: pass shader source keys to the disk cache 2017-08-25 13:20:29 +10:00
drirc drirc: enable glthread for more games (Civ5, CivBE, Dreamfall, Hitman, SR3) 2017-09-14 21:02:36 +02:00
format_r11g11b10f.h util: consistently use ifndef guards over pragma once 2017-03-22 16:55:22 +00:00
format_rgb9e5.h util/format: Use explicitly sized types 2016-08-05 09:07:04 -07:00
format_srgb.h util: Tiny optimisation for the linear→srgb conversion 2015-11-27 10:55:22 +01:00
format_srgb.py util: remove shebang from format_srgb.py 2017-03-10 14:12:48 +00:00
half_float.c glsl: move half<->float convertion to util 2015-10-16 19:33:37 -04:00
half_float.h glsl: move half<->float convertion to util 2015-10-16 19:33:37 -04:00
hash_table.c util: fix warning/error on 32bit build 2017-07-25 12:54:33 +03:00
hash_table.h mesa/util: add a hash table wrapper which support 64-bit keys 2017-06-14 10:04:35 +02:00
list.h util: #include "c99_compat.h" to fix Windows build 2017-04-03 13:09:05 -06:00
macros.h util: use cannonical form of ARRAY_SIZE 2017-08-02 20:43:33 +01:00
Makefile.am configure: check if -latomic is needed for __atomic_* 2017-09-22 17:01:21 +03:00
Makefile.sources util: Add a string buffer implementation 2017-09-26 18:24:33 +02:00
merge_driinfo.py util: add merge_driinfo.py 2017-08-02 09:50:57 +02:00
mesa-sha1.c util/sha1: harmonize _mesa_sha1_* wrappers 2017-03-22 11:33:51 +00:00
mesa-sha1.h util: #include "c99_compat.h" to fix Windows build 2017-04-03 13:09:05 -06:00
ralloc.c util/ralloc: set prev-pointers correctly in ralloc_adopt 2017-09-06 09:56:19 +02:00
ralloc.h util/ralloc: add ralloc_str_append() helper 2017-08-11 10:43:31 +10:00
rand_xor.c util/rand_xor: add missing include statements 2017-06-01 14:26:12 +01:00
rand_xor.h util/rand_xor: add function to seed rand 2017-03-23 08:16:29 +11:00
register_allocate.c util/ra: fix memory leak 2017-07-31 12:55:19 -07:00
register_allocate.h ra: Add a callback for selecting a register from what's available. 2017-07-25 14:44:52 -07:00
rgtc.c util: move shared rgtc code to util (v2) 2014-09-17 11:27:25 +10:00
rgtc.h util: move shared rgtc code to util (v2) 2014-09-17 11:27:25 +10:00
roundeven_test.c util: Add a roundeven test. 2015-03-18 21:06:26 -07:00
rounding.h util: try to use SSE instructions with MSVC and 32-bit gcc 2016-08-17 12:53:20 -06:00
SConscript Attempt to fix AppVeyor build, round 2 2017-07-31 17:19:13 +02:00
set.c util: make set's deleted_key_value declaration consistent with hash table one 2017-06-08 09:26:44 +02:00
set.h util/hash_set: Rework the API to know about hashing 2015-01-15 13:21:27 -08:00
simple_list.h mesa: Port a variant of 68afbe89c7 to util/ 2015-01-28 16:33:34 -08:00
slab.c util: slab_destroy_child should check whether it's been initialized 2017-05-29 01:52:16 +02:00
slab.h util/slab: re-design to allow migration between pools (v3) 2016-10-05 15:40:40 +02:00
string_buffer.c util: Add a string buffer implementation 2017-09-26 18:24:33 +02:00
string_buffer.h util: Add a string buffer implementation 2017-09-26 18:24:33 +02:00
strndup.h util/strndup: move header inclusion as applicable 2017-03-22 16:55:23 +00:00
strtod.c util: improve compiler guard 2017-09-03 09:05:23 +01:00
strtod.h mesa/main: free locale at exit 2015-06-29 09:06:40 -07:00
texcompress_rgtc_tmp.h util: move shared rgtc code to util (v2) 2014-09-17 11:27:25 +10:00
u_atomic.c util/u_atomic: remove unnecessaty __atomic functions 2017-09-22 17:12:24 +03:00
u_atomic.h util: use GCC atomic intrinsics with explicit memory model 2016-10-05 15:39:39 +02:00
u_atomic_test.c util: fix comment typo 2015-12-04 14:06:41 +00:00
u_dynarray.h mesa/util: add util_dynarray_clear() helper 2017-06-18 14:10:32 +02:00
u_endian.h u_endian: add android to glibc clause 2016-09-13 10:04:13 +10:00
u_queue.c util: only use SCHED_IDLE in pthread_setschedparam() when it's defined 2017-09-01 01:10:32 +02:00
u_queue.h util/u_queue: add an option to resize the queue when it's full 2017-07-17 10:57:20 -04:00
u_string.h gallium/util: move u_string.h to src/util/u_string.h 2017-03-12 17:43:06 +11:00
u_thread.h util: move pipe_thread_is_self from gallium to src/util 2017-06-26 02:17:03 +02:00
u_vector.c anv: Move a comment that got left behind in the u_vector refactor. 2017-08-18 11:56:58 -07:00
u_vector.h util: Remove u_math from u_vector 2017-07-14 14:14:05 +01:00
xmlconfig.c xmlconfig: use the portable __VA_ARGS__ 2017-08-26 11:20:06 +01:00
xmlconfig.h xmlconfig: move into src/util 2017-07-31 15:38:41 +02:00
xmlpool.h xmlconfig: move into src/util 2017-07-31 15:38:41 +02:00