From a2179f48c86e81dfe75a71935340b38342c60ff1 Mon Sep 17 00:00:00 2001 From: Jason Heeris Date: Mon, 10 May 2021 21:55:01 +0800 Subject: [PATCH] Make the comment for capn_size() clearer that it only applies to unpacked serialisation. --- lib/capnp_c.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/capnp_c.h b/lib/capnp_c.h index 7308c7e..6cf7ace 100644 --- a/lib/capnp_c.h +++ b/lib/capnp_c.h @@ -276,9 +276,11 @@ void capn_init_malloc(struct capn *c); int capn_init_fp(struct capn *c, FILE *f, int packed); int capn_init_mem(struct capn *c, const uint8_t *p, size_t sz, int packed); -/* capn_size calculates the amount of memory required for the buffer passed to - * capn_write_mem. It does not calculate the size for packed serialization, but - * that will always be less than the unpacked size. +/* capn_size() calculates the amount of memory required to serialise the given + * Cap'n Proto structure in the unpacked format. It does NOT apply to packed + * serialisation, as that may (in rare cases) actually become bigger than the + * input. A buffer of this size can then be passed to capn_write_mem() without + * fear of truncation (again, only in the unpacked case). */ int capn_size(struct capn *c);