make sure buffer_get tries to get all the bytes it was asked for

master
leitner 20 years ago
parent f141d3e24f
commit 636cfb70b0

@ -2,11 +2,18 @@
#include "buffer.h"
int buffer_get(buffer* b,char* x,unsigned long int len) {
unsigned long done;
int blen;
if ((blen=buffer_feed(b))<0) return blen;
done=0;
while (len) {
if ((blen=buffer_feed(b))<=0) return blen;
if ((unsigned long int) blen>=len)
blen=len;
byte_copy(x,blen,b->x+b->p);
b->p+=blen;
return blen;
len-=blen;
x+=blen;
done+=blen;
}
return done;
}

Loading…
Cancel
Save