Commit 005c1275 authored by rswindell's avatar rswindell
Browse files

Fixed the gcc warning regarding strlen - needed to #include string.h.

Changed all the malloc/realloc/free stuff to std C (no legacy macros).
parent 2f378b90
......@@ -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);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment