Mercurial > code
comparison buffer.c @ 45:86dbd57a39de
Do not free data in buffer_clear, we may want reusing
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 05 Oct 2011 12:10:55 +0200 |
parents | 5252fa9b5cb1 |
children | b71851428849 |
comparison
equal
deleted
inserted
replaced
44:295e76f7bd28 | 45:86dbd57a39de |
---|---|
207 */ | 207 */ |
208 | 208 |
209 void | 209 void |
210 buffer_clear(struct buffer *buf) | 210 buffer_clear(struct buffer *buf) |
211 { | 211 { |
212 buf->length = 0; | |
213 buf->size = 0; | |
214 } | |
215 | |
216 void | |
217 buffer_free(struct buffer *buf) | |
218 { | |
219 buffer_clear(buf); | |
220 | |
212 if (buf->data) | 221 if (buf->data) |
213 free(buf->data); | 222 free(buf->data); |
214 | 223 |
215 buf->length = 0; | |
216 buf->size = 0; | |
217 } | |
218 | |
219 void | |
220 buffer_free(struct buffer *buf) | |
221 { | |
222 buffer_clear(buf); | |
223 free(buf); | 224 free(buf); |
224 } | 225 } |
225 | 226 |
226 /* | 227 /* |
227 * Functions that tries to extend the buffer to the `needed' size if the buffer | 228 * Functions that tries to extend the buffer to the `needed' size if the buffer |