str.c revision 513928e1d3eb3943c535732d693eadc387a4c2c3
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen/* Copyright (c) 2002-2014 Dovecot authors, see the included COPYING file */
cce169a321c9c629e4f2db1a69dae3b75bbcb27aTimo Sirainenstring_t *str_new(pool_t pool, size_t initial_size)
cce169a321c9c629e4f2db1a69dae3b75bbcb27aTimo Sirainen /* never allocate a 0 byte size buffer. this is especially important
0ea17cea21df405e6e74a167d08e1ff0ee95dd13Timo Sirainen when str_c() is called on an empty string from a different stack
0ea17cea21df405e6e74a167d08e1ff0ee95dd13Timo Sirainen frame (see the comment in buffer.c about this). */
0ea17cea21df405e6e74a167d08e1ff0ee95dd13Timo Sirainen return buffer_create_dynamic(pool, I_MAX(initial_size, 1));
0ea17cea21df405e6e74a167d08e1ff0ee95dd13Timo Sirainenstring_t *str_new_const(pool_t pool, const char *str, size_t len)
785d9cca224d33ca3938e9166784f6483e8a27d7Timo Sirainen buffer_create_from_const_data(ret, str, len + 1);
cce169a321c9c629e4f2db1a69dae3b75bbcb27aTimo Sirainen return str_new(pool_datastack_create(), initial_size);
cce169a321c9c629e4f2db1a69dae3b75bbcb27aTimo Sirainenstring_t *t_str_new_const(const char *str, size_t len)
return FALSE;
len = 0;
len++;
const char *cstr;
char *tmp;
unsigned int init_size;