src/stdlib/zstr.c
/* reallocate buffer to be at least newmax */
reallocate buffer to be at least newmax
reallocate buffer to be at least newmax
static void
zalloc (ZSTR zstr, unsigned int newmax)
{
	char * ptr;
	int len = zs_len(zstr);
	while (zstr->max < newmax)
		zstr->max = zstr->max << 1;
	ptr = (char *)malloc(zstr->max);
	memcpy(ptr, zstr->str, len+1);
	free(zstr->str);
	zstr->str = ptr;
	zstr->end = zstr->str + len;
	DBGCHK(zstr);
}
static void zalloc ( ZSTR zstr , unsigned int newmax ) { char * ptr ; int len = zs_len ( zstr ) ; while ( zstr -> max < newmax ) zstr -> max = zstr -> max << 1 ; ptr = ( char * ) malloc ( zstr -> max ) ; memcpy ( ptr , zstr -> str , len + 1 ) ; free ( zstr -> str ) ; zstr -> str = ptr ; zstr -> end = zstr -> str + len ; DBGCHK ( zstr ) ; }
reallocate buffer to be at least newmax
reallocate buffer to be at least newmax
/* use memcpy not strcpy in case has embedded nulls */