From 29acb6756688dbf6fe40951215034a59ba3c0393 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Thu, 15 Feb 2018 22:43:43 +0100 Subject: [PATCH] Update example of snapshot to a better one. --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index fe1e1e54..04324a06 100644 --- a/README.md +++ b/README.md @@ -2065,13 +2065,15 @@ The object oplist is expected to have the following operators (INIT, INIT\_SET, Example: SNAPSHOT_DEF(snapshot_uint, unsigned int) - void f(unsigned int * i) { - snapshot_uint_t t; - snapshot_uint_init(t); - i = snapshot_uint_write(t); - *i = 1; - i = snapshot_uint_read(t); - snapshot_uint_clear(t); + snapshot_uint_t message; + void f(unsigned int i) { + unsigned *p = snapshot_uint_get_write_buffer(message); + *p = i; + snapshot_uint_write(message); + } + unsigned int g(void) { + unsigned *p = snapshot_uint_read(message); + return *p; }