libowfat/stralloc/stralloc_copyb.c

15 lines
418 B
C
Raw Normal View History

2001-02-02 17:54:47 +00:00
#include "byte.h"
#include "stralloc.h"
/* stralloc_copyb copies the string buf[0], buf[1], ..., buf[len-1] into
* sa, allocating space if necessary, and returns 1. If it runs out of
* memory, stralloc_copyb leaves sa alone and returns 0. */
2006-11-07 17:56:05 +00:00
int stralloc_copyb(stralloc *sa,const char *buf,size_t len) {
2001-02-02 17:54:47 +00:00
if (stralloc_ready(sa,len)) {
sa->len=len;
byte_copy(sa->s,len,buf);
return 1;
}
return 0;
}