comparison src/dmgrowbuf.c @ 2414:69a5af2eb1ea

Remove useless dmMemset().
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 13 Jan 2020 23:27:01 +0200
parents c801995cbb13
children c6ee41fd98dd
comparison
equal deleted inserted replaced
2413:902cc22018a1 2414:69a5af2eb1ea
20 DM_DBG("dmGrowBufInit(%p)\n", buf); 20 DM_DBG("dmGrowBufInit(%p)\n", buf);
21 21
22 if (buf == NULL) 22 if (buf == NULL)
23 return DMERR_NULLPTR; 23 return DMERR_NULLPTR;
24 24
25 dmMemset(buf, 0, sizeof(DMGrowBuf)); 25 memset(buf, 0, sizeof(DMGrowBuf));
26 26
27 return DMERR_OK; 27 return DMERR_OK;
28 } 28 }
29 29
30 30
66 66
67 if (buf->is_const) 67 if (buf->is_const)
68 return; 68 return;
69 69
70 dmFree(buf->data); 70 dmFree(buf->data);
71 dmMemset(buf, 0, sizeof(DMGrowBuf)); 71 memset(buf, 0, sizeof(DMGrowBuf));
72 } 72 }
73 } 73 }
74 74
75 75
76 DMGrowBuf * dmGrowBufCopy(DMGrowBuf *dst, const DMGrowBuf *src, const size_t enlarge) 76 DMGrowBuf * dmGrowBufCopy(DMGrowBuf *dst, const DMGrowBuf *src, const size_t enlarge)
88 88
89 // Allocate new memory for the data 89 // Allocate new memory for the data
90 if ((dst->data = dmMalloc(dst->size)) == NULL) 90 if ((dst->data = dmMalloc(dst->size)) == NULL)
91 { 91 {
92 // If that fails, clear the struct 92 // If that fails, clear the struct
93 dmMemset(dst, 0, sizeof(DMGrowBuf)); 93 memset(dst, 0, sizeof(DMGrowBuf));
94 return NULL; 94 return NULL;
95 } 95 }
96 96
97 // Copy data 97 // Copy data
98 memcpy(dst->data, src->data, src->size); 98 memcpy(dst->data, src->data, src->size);
99 if (enlarge > 0) 99 if (enlarge > 0)
100 dmMemset(dst->data + src->size, 0, enlarge); 100 memset(dst->data + src->size, 0, enlarge);
101 101
102 // And reset some struct information 102 // And reset some struct information
103 dst->is_const = FALSE; 103 dst->is_const = FALSE;
104 104
105 return dst; 105 return dst;
202 202
203 // Check if we need to clear the newly allocated area? 203 // Check if we need to clear the newly allocated area?
204 if (clear) 204 if (clear)
205 { 205 {
206 if (buf->backwards) 206 if (buf->backwards)
207 dmMemset(buf->data, 0, clrsize); 207 memset(buf->data, 0, clrsize);
208 else 208 else
209 dmMemset(buf->data + buf->size, 0, clrsize); 209 memset(buf->data + buf->size, 0, clrsize);
210 } 210 }
211 211
212 buf->size = nsize; 212 buf->size = nsize;
213 213
214 return TRUE; 214 return TRUE;