diff --git a/src/xpdev/sockwrap.c b/src/xpdev/sockwrap.c index b0730b04770e5b7bcb8f4a711d200442c0f0b48e..864b02db91f1af5d11d3be4ad2c93d739eb48237 100644 --- a/src/xpdev/sockwrap.c +++ b/src/xpdev/sockwrap.c @@ -35,7 +35,7 @@ * Note: If this box doesn't appear square, then you need to fix your tabs. * ****************************************************************************/ -#include <stdlib.h> /* malloc/free on FreeBSD */ +#include <stdlib.h> /* alloca/free on FreeBSD */ #include <string.h> /* bzero (for FD_ZERO) on FreeBSD */ #include <errno.h> /* ENOMEM */ #include <stdio.h> /* SEEK_SET */ @@ -245,7 +245,7 @@ int recvfilesocket(int sock, int file, long *offset, long count) return(-1); } - if((buf=(char*)malloc(count))==NULL) { + if((buf=(char*)alloca(count))==NULL) { errno=ENOMEM; return(-1); } @@ -255,13 +255,10 @@ int recvfilesocket(int sock, int file, long *offset, long count) return(-1); rd=read(sock,buf,count); - if(rd!=count) { - free(buf); + if(rd!=count) return(-1); - } wr=write(file,buf,rd); - free(buf); if(offset!=NULL) (*offset)+=wr; diff --git a/src/xpdev/str_list.c b/src/xpdev/str_list.c index 5cc356434f2768531b2fe3e15a4d714cf1bf026c..cf7c3d01269d5ef2567acbff7bd6e762c7fa003a 100644 --- a/src/xpdev/str_list.c +++ b/src/xpdev/str_list.c @@ -366,7 +366,7 @@ static str_list_t str_list_read_file(FILE* fp, str_list_t* lp, size_t max_line_l count=strListCount(*lp); while(!feof(fp)) { - if(buf==NULL && (buf=(char*)malloc(max_line_len+1))==NULL) + if(buf==NULL && (buf=(char*)alloca(max_line_len+1))==NULL) return(NULL); if(fgets(buf,max_line_len+1,fp)==NULL) @@ -374,9 +374,6 @@ static str_list_t str_list_read_file(FILE* fp, str_list_t* lp, size_t max_line_l strListAppend(lp, buf, count++); } - if(buf!=NULL) - free(buf); - return(*lp); }