diff options
-rw-r--r-- | pack.h | 1 | ||||
-rw-r--r-- | unpack.c | 3 |
2 files changed, 3 insertions, 1 deletions
@@ -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 { @@ -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++; } |