From fc13f284179df5f3f3a1d475bf84da21dc89c970 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Apr 2006 01:43:13 +0000 Subject: r15030: On a performace hunt... Remove as many extraneous memset's as possible. Jeremy. (This used to be commit 1217ed392b75aa8bfefa9c3f1ec5fa3bba841ee0) --- source3/lib/util.c | 3 ++- source3/lib/util_sock.c | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util.c b/source3/lib/util.c index 87f15b8759..bbc9ceddca 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -529,8 +529,9 @@ void smb_setlen(char *buf,int len) int set_message(char *buf,int num_words,int num_bytes,BOOL zero) { - if (zero) + if (zero && (num_words || num_bytes)) { memset(buf + smb_size,'\0',num_words*2 + num_bytes); + } SCVAL(buf,smb_wct,num_words); SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes); smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4); diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 91c3305996..12fc2ead95 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -662,8 +662,6 @@ BOOL receive_smb_raw(int fd, char *buffer, unsigned int timeout) smb_read_error = 0; - memset(buffer,'\0',smb_size + 100); - len = read_smb_length_return_keepalive(fd,buffer,timeout); if (len < 0) { DEBUG(10,("receive_smb_raw: length < 0!\n")); @@ -708,8 +706,9 @@ BOOL receive_smb_raw(int fd, char *buffer, unsigned int timeout) } if (ret != len) { - if (smb_read_error == 0) + if (smb_read_error == 0) { smb_read_error = READ_ERROR; + } return False; } -- cgit