add buffer_init_allocbuf, buffer_init_read, buffer_init_write, buffer_init_read_allocbuf, buffer_init_write_allocbuf

This commit is contained in:
leitner
2021-01-03 23:15:28 +00:00
parent 68a04bf226
commit e2673d3782
7 changed files with 72 additions and 2 deletions

View File

@@ -0,0 +1,13 @@
#include <stdlib.h>
#include <unistd.h>
#include "buffer.h"
int buffer_init_allocbuf(buffer* b, ssize_t (*op)(), int fd, size_t ylen) {
if (fd==-1) return -1;
char* thebuffer;
if (!(thebuffer=malloc(ylen)))
return -1;
buffer_init_free(b, op, fd, thebuffer, ylen);
return 0;
}