diff --git a/src/smblib/smbtxt.c b/src/smblib/smbtxt.c index 1edb8400e84000903c88d7700002f34629cce72a..0bd2cb18d24a83f66148d838de17c24b6c2dbd5d 100644 --- a/src/smblib/smbtxt.c +++ b/src/smblib/smbtxt.c @@ -36,12 +36,8 @@ ****************************************************************************/ /* ANSI */ - -#ifdef __unix__ - #include <stdlib.h> /* malloc/realloc/free is defined here */ -#else - #include <malloc.h> -#endif +#include <stdlib.h> /* malloc/realloc/free */ +#include <string.h> /* strlen */ /* SMB-specific */ #include "smblib.h" @@ -57,7 +53,7 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode) int lzh; /* BOOL */ long l=0,lzhlen,length; - if((buf=malloc(sizeof(char)))==NULL) { + if((buf=(char*)malloc(sizeof(char)))==NULL) { sprintf(smb->last_error ,"malloc failure of %u bytes for buffer" ,sizeof(char)); @@ -70,7 +66,7 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode) continue; str=(char*)msg->hfield_dat[i]; length=strlen(str)+2; /* +2 for crlf */ - if((p=(char*)REALLOC(buf,l+length+1))==NULL) { + if((p=(char*)realloc(buf,l+length+1))==NULL) { sprintf(smb->last_error ,"realloc failure of %ld bytes for comment buffer" ,l+length+1); @@ -111,7 +107,7 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode) length-=sizeof(xlat); if(length<1) continue; - if((lzhbuf=(char*)LMALLOC(length))==NULL) { + if((lzhbuf=(char*)malloc(length))==NULL) { sprintf(smb->last_error ,"malloc failure of %ld bytes for LZH buffer" ,length); @@ -119,20 +115,20 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode) } smb_fread(smb,lzhbuf,length,smb->sdt_fp); lzhlen=*(long*)lzhbuf; - if((p=(char*)REALLOC(buf,l+lzhlen+3L))==NULL) { + if((p=(char*)realloc(buf,l+lzhlen+3L))==NULL) { sprintf(smb->last_error ,"realloc failure of %ld bytes for text buffer" ,l+lzhlen+3L); - FREE(lzhbuf); + free(lzhbuf); return(buf); } buf=p; lzh_decode((char*)lzhbuf,length,(char*)buf+l); - FREE(lzhbuf); + free(lzhbuf); l+=lzhlen; } else { - if((p=(char*)REALLOC(buf,l+length+3L))==NULL) { + if((p=(char*)realloc(buf,l+length+3L))==NULL) { sprintf(smb->last_error ,"realloc failure of %ld bytes for text buffer" ,l+length+3L); @@ -160,5 +156,5 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode) void SMBCALL smb_freemsgtxt(char* buf) { if(buf!=NULL) - FREE(buf); + free(buf); }