src/stdlib/zstr.c
/* create & return new zstring with underlying buffer at least min bytes */
create & return new zstring with underlying buffer at least min bytes
create & return new zstring with underlying buffer at least min bytes
ZSTR
zs_newn (unsigned int min)
{
	ZSTR zstr = (ZSTR)malloc(sizeof(*zstr));
	unsigned int bksiz = (min<2048)?(min<64?32:128):(min<16384?2048:16384);
	while (bksiz < min)
		bksiz = bksiz << 1;
	init_zstr_vtable(zstr);
	zstr->str = (char *)malloc(bksiz);
	zstr->str[0] = 0;
	zstr->end = zstr->str;
	zstr->max = bksiz;
	zstr->magic = 7843;
	DBGCHK(zstr);
	return zstr;
}
ZSTR zs_newn ( unsigned int min ) { ZSTR zstr = ( ZSTR ) malloc ( sizeof ( * zstr ) ) ; unsigned int bksiz = ( min < 2048 ) ? ( min < 64 ? 32 : 128 ) : ( min < 16384 ? 2048 : 16384 ) ; while ( bksiz < min ) bksiz = bksiz << 1 ; init_zstr_vtable ( zstr ) ; zstr -> str = ( char * ) malloc ( bksiz ) ; zstr -> str [ 0 ] = 0 ; zstr -> end = zstr -> str ; zstr -> max = bksiz ; zstr -> magic = 7843 ; DBGCHK ( zstr ) ; return zstr ; }
create & return new zstring with underlying buffer at least min bytes
create & return new zstring with underlying buffer at least min bytes