more alloca fixes

master
leitner 21 years ago
parent 60d00ede11
commit f52aa87441

@ -19,6 +19,7 @@
head -1 -> head -n 1
apending 0 bytes to an empty array would fail it
remove socket_sendfile now that we have io_sendfile
break out alloca #include dependency into havealloca.h
0.16:
add buffer_fromsa (make buffer from stralloc)

@ -141,7 +141,7 @@ libepoll havesigio.h havebsdsf.h havescope.h havedevpoll.h Makefile dep
INCLUDES=buffer.h byte.h fmt.h ip4.h ip6.h mmap.h scan.h socket.h str.h stralloc.h \
uint16.h uint32.h uint64.h open.h textcode.h tai.h taia.h dns.h iopause.h case.h \
openreadclose.h readclose.h ndelay.h array.h io.h safemult.h iob.h havealloca.h
openreadclose.h readclose.h ndelay.h array.h io.h safemult.h iob.h
install: libowfat.a
install -d $(INCLUDEDIR) $(MAN3DIR) $(LIBDIR)

@ -6,5 +6,5 @@ void array_cat(array* to,const array* const from) {
array_fail(to);
return;
}
return array_catb(to,from->p,from->initialized);
array_catb(to,from->p,from->initialized);
}

@ -0,0 +1,3 @@
#if defined(__linux__) || defined(_SGI_SOURCE)
#include <alloca.h>
#endif

@ -20,7 +20,7 @@ int64 iob_send(int64 s,io_batch* b) {
#endif
if (b->bytesleft==0) return 0;
last=(iob_entry*)(((char*)array_start(&b->b))+array_bytes(&b->b));
last=((char*)array_start(&b->b))+array_bytes(&b->b);
v=alloca(b->bufs*sizeof(struct iovec));
total=0;
for (;;) {

@ -2,9 +2,10 @@
int imult16(int16 a,int16 b,int16* c) {
int neg=(a<0);
uint16 d;
if (neg) a=-a;
if (b<0) { neg^=1; b=-b; }
if (umult16(a,b,c)) return 0;
if (neg) *c=-*c;
if (umult16(a,b,&d)) return 0;
*c=(neg?-d:d);
return 1;
}

@ -2,9 +2,10 @@
int imult32(int32 a,int32 b,int32* c) {
int neg=(a<0);
uint32 d;
if (neg) a=-a;
if (b<0) { neg^=1; b=-b; }
if (umult32(a,b,c)) return 0;
if (neg) *c=-*c;
if (umult32(a,b,&d)) return 0;
*c=(neg?-d:d);
return 1;
}

@ -2,10 +2,11 @@
int imult64(int64 a,int64 b,int64* c) {
int neg=(a<0);
uint64 d;
if (neg) a=-a;
if (b<0) { neg^=1; b=-b; }
if (umult64(a,b,c)) return 0;
if (neg) *c=-*c;
if (umult64(a,b,&d)) return 0;
*c=(neg?-d:d);
return 1;
}

@ -2,9 +2,7 @@
#include "byte.h"
#include <ctype.h>
#include "socket.h"
#if defined(__linux__) || defined(_SGI_SOURCE)
#include <alloca.h>
#endif
#include "havealloca.h"
unsigned int scan_ip6if(const char* src,char* ip,uint32* scope_id) {
int i=scan_ip6(src,ip);

@ -1,6 +1,7 @@
#include <string.h>
#include "buffer.h"
#include "textcode.h"
#include "havealloca.h"
void b64encode(const char* c) {
char* buf=alloca(strlen(c)*2+4);

@ -1,6 +1,7 @@
#include <string.h>
#include "buffer.h"
#include "textcode.h"
#include "havealloca.h"
void b64encode(const char* c) {
char* buf=alloca(strlen(c)*2+4);

@ -1,7 +1,7 @@
#include <string.h>
#include "buffer.h"
#include "textcode.h"
#include "havealloca.h"
void cescape(const char* c) {
char* buf=alloca(strlen(c)*5+1);

@ -1,6 +1,7 @@
#include <string.h>
#include "buffer.h"
#include "textcode.h"
#include "havealloca.h"
void unurl(const char* s) {
char* buf;

@ -1,6 +1,7 @@
#include <string.h>
#include "buffer.h"
#include "textcode.h"
#include "havealloca.h"
void urlencode(const char* c) {
char* buf=alloca(strlen(c)*3+1);

@ -10,7 +10,7 @@ unsigned long scan_tofrom_array(unsigned long (*func)(const char*,char*,unsigned
array_cat0(src);
if (array_failed(src) || array_failed(dest)) return 0;
needed=array_bytes(src);
x=array_start(dest)+array_bytes(dest);
x=((char*)array_start(dest))+array_bytes(dest);
if (!array_allocate(dest,1,array_bytes(dest)+needed-1)) return 0;
needed=func(array_start(src),x,&scanned);
array_truncate(src,1,array_bytes(src)-1);

Loading…
Cancel
Save