aboutsummaryrefslogtreecommitdiff
path: root/documentation
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-10-05 09:32:46 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-10-05 09:32:46 +0200
commit60329bef10f114dac7b9a01d9cd83d6ed25e97ac (patch)
tree0c515ca2320ea144ee0dc77cc11a1ecacf4d6e87 /documentation
parentbf0566e9542656da165a5cba1b1605980ba600b0 (diff)
Do complete error checking in the minimal examples
Diffstat (limited to 'documentation')
-rw-r--r--documentation/cxx/hybrid/guide/index.xhtml29
1 files changed, 27 insertions, 2 deletions
diff --git a/documentation/cxx/hybrid/guide/index.xhtml b/documentation/cxx/hybrid/guide/index.xhtml
index 460e3b2..39d7e9b 100644
--- a/documentation/cxx/hybrid/guide/index.xhtml
+++ b/documentation/cxx/hybrid/guide/index.xhtml
@@ -1153,11 +1153,36 @@ main (int argc, char* argv[])
// Change the greeting phrase.
//
- h->greeting (strdupx ("Hi"));
+ char* str = strdupx ("Hi");
+
+ if (str == 0)
+ {
+ fprintf (stderr, "error: no memory\n");
+ delete h;
+ return 1;
+ }
+
+ h->greeting (str);
// Add another entry to the name sequence.
//
- h->name ().push_back (strdupx ("mars"));
+ str = strdupx ("mars");
+
+ if (str == 0)
+ {
+ fprintf (stderr, "error: no memory\n");
+ delete h;
+ return 1;
+ }
+
+ if (h->name ().push_back (str) != 0)
+ {
+ // The sequence has already freed str.
+ //
+ fprintf (stderr, "error: no memory\n");
+ delete h;
+ return 1;
+ }
// Serialize.
//