comparison buffer.c @ 1044:a5b785c12340

Avoid cppcheck warning
author Thorsten Horstmann <thorsten.horstmann@web.de>
date Tue, 24 Feb 2015 22:41:26 +0800
parents 7c899f24a85b
children 16584026a1f0
comparison
equal deleted inserted replaced
1043:38d2f6b2d1b8 1044:a5b785c12340
97 97
98 buffer* ret; 98 buffer* ret;
99 99
100 ret = buf_new(buf->len); 100 ret = buf_new(buf->len);
101 ret->len = buf->len; 101 ret->len = buf->len;
102 memcpy(ret->data, buf->data, buf->len); 102 if (buf->len > 0) {
103 memcpy(ret->data, buf->data, buf->len);
104 }
103 return ret; 105 return ret;
104 } 106 }
105 107
106 /* Set the length of the buffer */ 108 /* Set the length of the buffer */
107 void buf_setlen(buffer* buf, unsigned int len) { 109 void buf_setlen(buffer* buf, unsigned int len) {