rioInitWithFile nad rioInitWithBuffer functions now take a rio structure pointer to avoid copying a structure to return value to the caller.

This commit is contained in:
antirez
2011-09-22 16:00:40 +02:00
parent 69cecb511f
commit f96a8a8054
5 changed files with 17 additions and 18 deletions

View File

@ -52,16 +52,15 @@ static const rio rioFileIO = {
{ { NULL, 0 } } /* union for io-specific vars */
};
rio rioInitWithFile(FILE *fp) {
rio r = rioFileIO;
r.io.file.fp = fp;
return r;
void rioInitWithFile(rio *r, FILE *fp) {
*r = rioFileIO;
r->io.file.fp = fp;
}
rio rioInitWithBuffer(sds s) {
rio r = rioBufferIO;
r.io.buffer.ptr = s;
r.io.buffer.pos = 0;
return r;
void rioInitWithBuffer(rio *r, sds s) {
*r = rioBufferIO;
r->io.buffer.ptr = s;
r->io.buffer.pos = 0;
}
/* Write multi bulk count in the format: "*<count>\r\n". */