diff options
author | Keith Bostic <keith@wiredtiger.com> | 2012-05-11 10:36:20 +0000 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2012-05-11 10:36:20 +0000 |
commit | 5a06143447e57a428aa85cd6fbb9c982831dcdb0 (patch) | |
tree | d4d14110220046b9b63c9524b50705f8ba2589ac /examples | |
parent | fdf043a1a7618b8df20867b99db9889ed89cbdb7 (diff) | |
download | mongo-5a06143447e57a428aa85cd6fbb9c982831dcdb0.tar.gz |
Change wiredtiger_struct_{size,pack,unpack} to take a WT_SESSION as their
first argument, they're calling underlying functions that need to handle
errors in appropriate ways.
Fix some related documentation problems.
__log_record_size was calling the wrong function, fix that while I'm in
the area.
ref #209.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/c/ex_all.c | 35 | ||||
-rw-r--r-- | examples/c/ex_pack.c | 6 |
2 files changed, 26 insertions, 15 deletions
diff --git a/examples/c/ex_all.c b/examples/c/ex_all.c index 893ad428e81..bdbca774d18 100644 --- a/examples/c/ex_all.c +++ b/examples/c/ex_all.c @@ -48,6 +48,7 @@ int add_extractor(WT_CONNECTION *conn); int connection_ops(WT_CONNECTION *conn); int cursor_ops(WT_SESSION *session); int cursor_search_near(WT_CURSOR *cursor); +int pack_ops(WT_SESSION *session); int session_ops(WT_SESSION *session); int @@ -686,22 +687,15 @@ connection_ops(WT_CONNECTION *conn) return (ret); } -int main(void) +int +pack_ops(WT_SESSION *session) { int ret; { - /*! [Open a connection] */ - WT_CONNECTION *conn; - const char *home = "WT_TEST"; - ret = wiredtiger_open(home, NULL, "create,transactional", &conn); - /*! [Open a connection] */ - } - - { /*! [Get the packed size] */ size_t size; - size = wiredtiger_struct_size("iSh", 42, "hello", -3); + size = wiredtiger_struct_size(session, "iSh", 42, "hello", -3); assert(size < 100); /*! [Get the packed size] */ } @@ -709,7 +703,8 @@ int main(void) { /*! [Pack fields into a buffer] */ char buf[100]; - ret = wiredtiger_struct_pack(buf, sizeof(buf), "iSh", 42, "hello", -3); + ret = wiredtiger_struct_pack( + session, buf, sizeof(buf), "iSh", 42, "hello", -3); /*! [Pack fields into a buffer] */ { @@ -717,11 +712,27 @@ int main(void) int i; char *s; short h; - ret = wiredtiger_struct_unpack(buf, sizeof(buf), "iSh", &i, &s, &h); + ret = wiredtiger_struct_unpack( + session, buf, sizeof(buf), "iSh", &i, &s, &h); /*! [Unpack fields from a buffer] */ } } + return (ret); +} + +int main(void) +{ + int ret; + + { + /*! [Open a connection] */ + WT_CONNECTION *conn; + const char *home = "WT_TEST"; + ret = wiredtiger_open(home, NULL, "create,transactional", &conn); + /*! [Open a connection] */ + } + /*! [Get the WiredTiger library version #1] */ printf("WiredTiger version %s\n", wiredtiger_version(NULL, NULL, NULL)); /*! [Get the WiredTiger library version #1] */ diff --git a/examples/c/ex_pack.c b/examples/c/ex_pack.c index 87344da3df4..e55e82d482c 100644 --- a/examples/c/ex_pack.c +++ b/examples/c/ex_pack.c @@ -54,12 +54,12 @@ int main(void) home, wiredtiger_strerror(ret)); /*! [packing] */ - size = wiredtiger_struct_size("iii", 42, 1000, -9); + size = wiredtiger_struct_size(session, "iii", 42, 1000, -9); if (size > sizeof(buf)) { /* Allocate a bigger buffer. */ } - wiredtiger_struct_pack(buf, size, "iii", 42, 1000, -9); - wiredtiger_struct_unpack(buf, size, "iii", &i, &j, &k); + wiredtiger_struct_pack(session, buf, size, "iii", 42, 1000, -9); + wiredtiger_struct_unpack(session, buf, size, "iii", &i, &j, &k); /*! [packing] */ /* Note: closing the connection implicitly closes open session(s). */ |