22 lines
640 B
Diff
Raw Normal View History

diff --git a/zbar/decoder.c b/zbar/decoder.c
index 7f7336f..e9ffc45 100644
--- a/zbar/decoder.c
+++ b/zbar/decoder.c
@@ -25,6 +25,7 @@
#include <stdlib.h> /* malloc, calloc, free */
#include <stdio.h> /* snprintf */
#include <string.h> /* memset, strlen */
+#include <stddef.h> /* offsetof */
#include <zbar.h>
@@ -113,7 +114,7 @@ void zbar_decoder_destroy (zbar_decoder_t *dcode)
void zbar_decoder_reset (zbar_decoder_t *dcode)
{
- memset(dcode, 0, (long)&dcode->buf_alloc - (long)dcode);
+ memset(dcode, 0, offsetof(zbar_decoder_t, buf_alloc));
#if ENABLE_EAN == 1
ean_reset(&dcode->ean);
#endif