set_data.c
334 Bytes
#include <sys/types.h>
#include <string.h>
#include <errno.h>
#include "cbuf.h"
char *
cbufSetData(Cbuf this, const void * src, size_t n)
{
char * addr;
if (n > cbufGetFree(this)) {
errno = ECBUFOVFL;
return -1;
}
addr = memcpy(cbufGetWrite(this), src, n);
cbufIncWrite(this, n);
return addr;
}
// vim: set ts=4 sw=4: