2 * Copyright © 2017 Thomas Helland
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 #ifndef _STRING_BUFFER_H
25 #define _STRING_BUFFER_H
38 struct _mesa_string_buffer
{
44 struct _mesa_string_buffer
*
45 _mesa_string_buffer_create(void *mem_ctx
, uint32_t initial_capacity
);
48 _mesa_string_buffer_destroy(struct _mesa_string_buffer
*str
)
54 _mesa_string_buffer_append_all(struct _mesa_string_buffer
*str
,
55 uint32_t num_args
, ...);
57 _mesa_string_buffer_append_len(struct _mesa_string_buffer
*str
,
58 const char *c
, uint32_t len
);
61 _mesa_string_buffer_append_char(struct _mesa_string_buffer
*str
, char c
)
63 return _mesa_string_buffer_append_len(str
, &c
, 1);
67 _mesa_string_buffer_append(struct _mesa_string_buffer
*str
, const char *c
)
69 return _mesa_string_buffer_append_len(str
, c
, strlen(c
));
73 _mesa_string_buffer_clear(struct _mesa_string_buffer
*str
)
76 str
->buf
[str
->length
] = '\0';
80 _mesa_string_buffer_crimp_to_fit(struct _mesa_string_buffer
*str
)
83 (char *) reralloc_array_size(str
, str
->buf
, sizeof(char),
88 str
->capacity
= str
->length
+ 1;
93 _mesa_string_buffer_vprintf(struct _mesa_string_buffer
*str
,
94 const char *format
, va_list args
);
97 _mesa_string_buffer_printf(struct _mesa_string_buffer
*str
,
98 const char *format
, ...);
104 #endif /* _STRING_BUFFER_H */