|
|
@ -9,7 +9,7 @@
|
|
|
|
* 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) wanted=len;
|
|
|
|
if (wanted<len) wanted=len; // in case of integer overflow
|
|
|
|
if (!sa->s || sa->a<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)))
|
|
|
|