|
|
@ -9,7 +9,8 @@
|
|
|
|
* old space, and returns 1. Note that this changes sa.s. */
|
|
|
|
* old space, and returns 1. Note that this changes sa.s. */
|
|
|
|
int stralloc_ready(stralloc *sa,size_t len) {
|
|
|
|
int stralloc_ready(stralloc *sa,size_t len) {
|
|
|
|
register size_t wanted=len+(len>>3)+30; /* heuristic from djb */
|
|
|
|
register size_t wanted=len+(len>>3)+30; /* heuristic from djb */
|
|
|
|
if (wanted<len || !sa->s || sa->a<len) {
|
|
|
|
if (wanted<len) wanted=len;
|
|
|
|
|
|
|
|
if (!sa->s || sa->a<len) {
|
|
|
|
register char* tmp;
|
|
|
|
register char* tmp;
|
|
|
|
if (!(tmp=realloc(sa->s,wanted)))
|
|
|
|
if (!(tmp=realloc(sa->s,wanted)))
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|