str.c revision 33ca6b017b6ebbd048651b5e3d16915001dbc291
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen Copyright (c) 2002 Timo Sirainen
e05a4c4136fec723f019bee8383103080203f127Timo Sirainen Permission is hereby granted, free of charge, to any person obtaining
50c617761ee9653bd44646a95178773a3686d62eTimo Sirainen a copy of this software and associated documentation files (the
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen "Software"), to deal in the Software without restriction, including
e2d268e9531227ead6a98466ecf3c046c857ef70Timo Sirainen without limitation the rights to use, copy, modify, merge, publish,
2b9dbb270ad82e58d5f3581436e6f143176d5819Timo Sirainen distribute, sublicense, and/or sell copies of the Software, and to
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen permit persons to whom the Software is furnished to do so, subject to
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen the following conditions:
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen The above copyright notice and this permission notice shall be
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen included in all copies or substantial portions of the Software.
128ea07dab8d67124ea74bcc085a478784b6358aTimo Sirainen THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
c04f9a724a7b3cc649485a61b0a540868d25d71bTimo Sirainen OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
e2d268e9531227ead6a98466ecf3c046c857ef70Timo Sirainen MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
e2d268e9531227ead6a98466ecf3c046c857ef70Timo Sirainen IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
c04f9a724a7b3cc649485a61b0a540868d25d71bTimo Sirainen CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
d1fbd2c264368d8b4c7139b96e3b21f45930b857Timo Sirainen TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
eb0816090cf5a549280ad783b9aa6fec199d36baTimo Sirainen/* @UNSAFE: whole file */
eb0816090cf5a549280ad783b9aa6fec199d36baTimo SirainenString *str_new(Pool pool, size_t initial_size)
2b9dbb270ad82e58d5f3581436e6f143176d5819Timo Sirainen return buffer_create_dynamic(pool, initial_size, (size_t)-1);
661998e2ccd772ad92a9d4a75cb712692a8c94b3Timo Sirainen return str_new(data_stack_pool, initial_size);
50c617761ee9653bd44646a95178773a3686d62eTimo Sirainen /* no space - doesn't happen with our dynamically growing
50c617761ee9653bd44646a95178773a3686d62eTimo Sirainen strings though, but make sure it's \0 terminated. */
eb0816090cf5a549280ad783b9aa6fec199d36baTimo Sirainen /* remove the \0 - we don't want to keep it */
e2d268e9531227ead6a98466ecf3c046c857ef70Timo Sirainenvoid str_append_n(String *str, const char *cstr, size_t max_len)
acfeae4e2b5c2acdab88a1377ff6cd4a9b5f0a3aTimo Sirainenvoid str_append_str(String *dest, const String *src)
c04f9a724a7b3cc649485a61b0a540868d25d71bTimo Sirainenvoid str_printfa(String *str, const char *fmt, ...)
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainenvoid str_vprintfa(String *str, const char *fmt, va_list args)
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen buf = buffer_append_space(str, printf_string_upper_bound(fmt, args));