From 61ead850cd25cb514ea25d941dc8878da01e06cb Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Tue, 30 Oct 2001 18:12:13 +0000 Subject: [PATCH] Fixed malloc/realloc warnings on FreeBSD by #including stdlib.h instead of malloc.h. --- src/sbbs3/ringbuf.c | 10 ++++++---- src/sbbs3/sbbsecho.c | 5 ++++- src/smblib/smbtxt.c | 14 +++++++++----- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/sbbs3/ringbuf.c b/src/sbbs3/ringbuf.c index fd9d7bea2e..8c6728b91e 100644 --- a/src/sbbs3/ringbuf.c +++ b/src/sbbs3/ringbuf.c @@ -52,11 +52,13 @@ #ifndef VTOOLSD /* FreeBSD uses <stdlib.h> instead of <malloc.h> */ - #ifndef __FreeBSD__ - #include <malloc.h> /* malloc prototype */ + #ifdef __FreeBSD__ + #include <stdlib.h> + #else + #include <malloc.h> /* malloc prototype */ #endif - #include <string.h> /* memcpy prototype */ - #endif + #include <string.h> /* memcpy prototype */ + #endif /* !VTOOLSD */ #define os_malloc malloc #define rb_malloc malloc diff --git a/src/sbbs3/sbbsecho.c b/src/sbbs3/sbbsecho.c index 0d9af957af..28c829a099 100644 --- a/src/sbbs3/sbbsecho.c +++ b/src/sbbs3/sbbsecho.c @@ -20,7 +20,6 @@ #include <ctype.h> #include <fcntl.h> #include <share.h> -#include <malloc.h> #include <stdarg.h> #include <stdlib.h> #include <string.h> @@ -31,6 +30,10 @@ #include <mem.h> #endif +#ifndef __FreeBSD__ + #include <malloc.h> +#endif + #include "sbbs.h" /* load_cfg() */ #include "smbwrap.h" /* lock/unlock() */ #include "sbbswrap.h" /* glob_t */ diff --git a/src/smblib/smbtxt.c b/src/smblib/smbtxt.c index 49db571c11..76477e0097 100644 --- a/src/smblib/smbtxt.c +++ b/src/smblib/smbtxt.c @@ -37,7 +37,9 @@ /* ANSI */ -#ifndef __FreeBSD__ +#ifdef __FreeBSD__ + #include <stdlib.h> /* malloc/realloc/free is defined here */ +#else #include <malloc.h> #endif @@ -46,7 +48,9 @@ char HUGE16* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode) { - char HUGE16* buf=NULL,HUGE16* lzhbuf,HUGE16* p; + char HUGE16* buf=NULL; + char HUGE16* lzhbuf; + char HUGE16* p; ushort xlat; int i,lzh; long l=0,lzhlen,length; @@ -72,7 +76,7 @@ char HUGE16* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode) length-=2; if(length<1) continue; - if((lzhbuf=LMALLOC(length))==NULL) { + if((lzhbuf=(char HUGE16*)LMALLOC(length))==NULL) { sprintf(smb->last_error ,"malloc failure of %ld bytes for LZH buffer" ,length); @@ -80,7 +84,7 @@ char HUGE16* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode) } smb_fread(lzhbuf,length,smb->sdt_fp); lzhlen=*(long*)lzhbuf; - if((p=REALLOC(buf,l+lzhlen+3L))==NULL) { + if((p=(char HUGE16*)REALLOC(buf,l+lzhlen+3L))==NULL) { sprintf(smb->last_error ,"realloc failure of %ld bytes for text buffer" ,l+lzhlen+3L); @@ -93,7 +97,7 @@ char HUGE16* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode) l+=lzhlen; } else { - if((p=REALLOC(buf,l+length+3L))==NULL) { + if((p=(char HUGE16*)REALLOC(buf,l+length+3L))==NULL) { sprintf(smb->last_error ,"realloc failure of %ld bytes for text buffer" ,l+length+3L); -- GitLab