libowfat/stralloc/stralloc_readyplus.c

14 lines
417 B
C
Raw Normal View History

2001-02-02 17:54:47 +00:00
#include "stralloc.h"
#include <stdlib.h>
/* stralloc_readyplus is like stralloc_ready except that, if sa is
* already allocated, stralloc_readyplus adds the current length of sa
* to len. */
2006-11-07 17:56:05 +00:00
int stralloc_readyplus(stralloc *sa,size_t len) {
if (sa->s) {
if (sa->len + len < len) return 0; /* catch integer overflow */
2001-02-02 17:54:47 +00:00
return stralloc_ready(sa,sa->len+len);
} else
2001-02-02 17:54:47 +00:00
return stralloc_ready(sa,len);
}