add buffer_fromarray, buffer_frombuf
parent
875c0dc491
commit
24d8e81116
@ -0,0 +1,9 @@
|
||||
#include "array.h"
|
||||
#include "buffer.h"
|
||||
|
||||
void buffer_fromarray(buffer* b,array* a) {
|
||||
if (array_failed(a))
|
||||
buffer_frombuf(b,NULL,0);
|
||||
else
|
||||
buffer_frombuf(b,array_start(a),a->initialized);
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
#include "stralloc.h"
|
||||
#include "buffer.h"
|
||||
|
||||
static ssize_t dummyreadwrite(int fd,char* buf,size_t len) {
|
||||
(void)fd;
|
||||
(void)buf;
|
||||
(void)len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void buffer_frombuf(buffer* b,const char* x,size_t l) {
|
||||
b->x=x;
|
||||
b->p=0;
|
||||
b->n=l;
|
||||
b->a=l;
|
||||
b->fd=0;
|
||||
b->op=dummyreadwrite;
|
||||
}
|
@ -1,18 +1,6 @@
|
||||
#include "stralloc.h"
|
||||
#include "buffer.h"
|
||||
|
||||
static ssize_t dummyreadwrite(int fd,char* buf,size_t len) {
|
||||
(void)fd;
|
||||
(void)buf;
|
||||
(void)len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void buffer_fromsa(buffer* b,stralloc* sa) {
|
||||
b->x=sa->s;
|
||||
b->p=0;
|
||||
b->n=sa->len;
|
||||
b->a=sa->a;
|
||||
b->fd=0;
|
||||
b->op=dummyreadwrite;
|
||||
buffer_frombuf(b,sa->s,sa->len);
|
||||
}
|
||||
|
Loading…
Reference in New Issue