aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pack.h1
-rw-r--r--unpack.c3
2 files changed, 3 insertions, 1 deletions
diff --git a/pack.h b/pack.h
index daf0699..7fd54a5 100644
--- a/pack.h
+++ b/pack.h
@@ -34,6 +34,7 @@ enum pack_type {
PACK_TYPE_FLOAT = 'f',
PACK_TYPE_DOUBLE = 'd',
PACK_TYPE_PADDING = 'x',
+ PACK_TYPE_COUNT = '*',
};
enum pack_endian {
diff --git a/unpack.c b/unpack.c
index 836faf3..8fd1d94 100644
--- a/unpack.c
+++ b/unpack.c
@@ -95,6 +95,7 @@ static void read_fields(struct dest dest, const void *src_, enum pack_endian end
case PACK_TYPE_FLOAT: dest.ptr.f[i] = val.f; break;
case PACK_TYPE_DOUBLE: dest.ptr.d[i] = val.d; break;
case PACK_TYPE_PADDING: break;
+ case PACK_TYPE_COUNT: return;
}
}
}
@@ -125,7 +126,7 @@ enum pack_status unpack(const void *buf_, size_t size, const char *fmt, ...)
SET_AND_GOTO(ret, PACK_FMTINVAL, stop);
dest.count = c;
i += end - &fmt[i];
- } else if (fmt[i] == '*') {
+ } else if (fmt[i] == PACK_TYPE_COUNT) {
dest.count = va_arg(ap, size_t);
i++;
}