Actually put the JSON doc into the user manual

The user manual include statment wasn't pulling the json section.
This change fixes that.

This change also closes some memory leaks in the json wrapper.

Signed-off-by: E. Scott Daniels <daniels@research.att.com>
Change-Id: I54849c67960fd945a85327a3ff308d7d7651b673
diff --git a/doc/src/user/Makefile b/doc/src/user/Makefile
index ca3c252..70ab002 100644
--- a/doc/src/user/Makefile
+++ b/doc/src/user/Makefile
@@ -17,6 +17,8 @@
 
 # this uses {X}fm which can be cloned from: https://gitlab.com/rouxware/xfm
 
+XPATH=XFM_PATH=.:/usr/local/share/xfm TFM_PATH=.:/usr/local/share/xfm
+
 docs = user_guide
 src = user_guide.xfm
 imbed_src = cpp_frame.im example1.im example2.im example3.im jhash.im
@@ -28,20 +30,20 @@
 # references etc.
 #
 %.ps: %.xfm
-	OUTPUT_TYPE=generic_ps XFM_PASS=1 pfm $< /dev/null
-	OUTPUT_TYPE=generic_ps XFM_PASS=2 pfm $< $@
+	$(XPATH) OUTPUT_TYPE=generic_ps XFM_PASS=1 pfm $< /dev/null
+	$(XPATH) OUTPUT_TYPE=generic_ps XFM_PASS=2 pfm $< $@
 
 %.md: %.xfm
-	OUTPUT_TYPE=markdown XFM_PASS=1 tfm $< /dev/null
-	OUTPUT_TYPE=markdown XFM_PASS=2 tfm $< | sed 's/^ //' >$@
+	$(XPATH) OUTPUT_TYPE=markdown XFM_PASS=1 tfm $< /dev/null
+	$(XPATH) OUTPUT_TYPE=markdown XFM_PASS=2 tfm $< | sed 's/^ //' >$@
 
 %.rst: %.xfm
-	OUTPUT_TYPE=rst XFM_PASS=1 tfm $< /dev/null
-	GEN_TITLE=1 OUTPUT_TYPE=rst XFM_PASS=2 tfm $< | sed 's/^ //; s/ *$$//' >$@
+	$(XPATH) OUTPUT_TYPE=rst XFM_PASS=1 tfm $< /dev/null
+	$(XPATH) GEN_TITLE=1 OUTPUT_TYPE=rst XFM_PASS=2 tfm $< | sed 's/^ //; s/ *$$//' >$@
 
 %.txt: %.xfm
-	OUTPUT_TYPE=txt XFM_PASS=1 tfm $< /dev/null
-	OUTPUT_TYPE=txt XFM_PASS=2 tfm $< $@
+	$(XPATH) OUTPUT_TYPE=txt XFM_PASS=1 tfm $< /dev/null
+	$(XPATH) OUTPUT_TYPE=txt XFM_PASS=2 tfm $< $@
 
 # -----------------------------------------------------------------------------------
 all:    $(desired_out:%=user_guide.%)
diff --git a/doc/src/user/cpp_frame.im b/doc/src/user/cpp_frame.im
index 9481b5a..0c7a560 100644
--- a/doc/src/user/cpp_frame.im
+++ b/doc/src/user/cpp_frame.im
@@ -41,10 +41,10 @@
 &half_space
 &indent
 &beg_dlist(.5i:&ditemtext)
-    &ditem(port) A C string (pointer to char) which defines the port that RMR will open to listen for connections.
+    &di(port) A C string (pointer to char) which defines the port that RMR will open to listen for connections.
     &half_space
 
-    &ditem(wait) A Boolean value which indicates whether or not the initialization process should wait for
+    &di(wait) A Boolean value which indicates whether or not the initialization process should wait for
         the arrival of a valid route table before completing.
         When true is supplied, the initialization will not complete until RMR has received a valid route table
         (or one is located via the &cw(RMR_SEED_RT) environment variable).
@@ -67,7 +67,7 @@
               new Xapp( listen_port, wait4table ) );
     }
 &ex_end
-&figure( Creating an xAPP instance.)
+&fig( Creating an xAPP instance.)
 &space
 
 From a compilation perspective, the following is the simple compiler invocation string needed to compile
@@ -106,31 +106,31 @@
           int payload_len, Msg_component payload,
           void* usr_data );
 &ex_end
-&figure( Callback function signature)
+&fig( Callback function signature)
 &space
 
 The parameters passed to the callback function are as follows:
-&multi_space( .1 )
+&mult_space( .1 )
 
 &indent
 &beg_dlist(1i:&ditemtext)
-    &ditem(m) A reference to the Message that was received.
+    &di(m) A reference to the Message that was received.
     &half_space
 
-    &ditem(mtype) The message type (allows for disambiguation if the callback is registered for multiple message types).
+    &di(mtype) The message type (allows for disambiguation if the callback is registered for multiple message types).
     &half_space
 
-    &ditem(subid) The subscription ID from the message.
+    &di(subid) The subscription ID from the message.
     &half_space
 
-    &ditem(payload len) The number of bytes which the sender has placed into the payload.
+    &di(payload len) The number of bytes which the sender has placed into the payload.
     &half_space
 
-    &ditem(payload) A direct reference (smart pointer) to the payload. (The smart pointer is wrapped in a
+    &di(payload) A direct reference (smart pointer) to the payload. (The smart pointer is wrapped in a
             special class in order to provide a custom destruction function without burdening the xApp developer
             with that knowledge.)
     &half_space
-    &ditem(user data) A pointer to user data. This is the pointer that was provided when the function was registered.
+    &di(user data) A pointer to user data. This is the pointer that was provided when the function was registered.
 &end_dlist
 &uindent
 &space
@@ -170,7 +170,7 @@
         xapp->Run( 1 );        // start the callback driver
     }
 &ex_end
-&figure( Callback function example.)
+&fig( Callback function example.)
 &space
 
 As before, the program does nothing useful, but now it will execute and receive messages.
@@ -209,10 +209,10 @@
 &half_space
 &indent
 &beg_list(&lic1)
-    &item Replying to the sender of a received message
+    &li Replying to the sender of a received message
     &half_space
 
-    &item Sending a message (routed based on the message type and subscription ID)
+    &li Sending a message (routed based on the message type and subscription ID)
 &end_list
 &uindent
 &space
@@ -232,7 +232,7 @@
 
    bool Send_response(  int response_len, std::shared_ptr<unsigned char> response );
 &ex_end
-&figure( Reply function prototypes. )
+&fig( Reply function prototypes. )
 &space
 
 In the first prototype the xApp must supply the new message type and subscription ID values, where the
@@ -248,7 +248,7 @@
     msg->Send_response( Message::NO_CHANGE, Message::NO_SUBID,
         pl_length, (unsigned char *) payload );
 &ex_end
-&figure( Send response prototype. )
+&fig( Send response prototype. )
 &space
 
 In addition to the two function prototypes for &cw(Send_response()) there are two additional prototypes
@@ -273,7 +273,7 @@
 
     bool Send_msg( int payload_len, unsigned char* payload );
 &ex_end
-&figure( Send function prototypes. )
+&fig( Send function prototypes. )
 &space
 
 Each send function accepts the message, copies in the payload provided, sets the message type and subscription
@@ -314,7 +314,7 @@
       msg->Send_response( M_TYPE, SID, strlen( raw_pl ), NULL );
     }
 &ex_end
-&figure( Send message without buffer copy. )
+&fig( Send message without buffer copy. )
 &space
 
 &h2(Sending Multiple Responses)
diff --git a/doc/src/user/example1.im b/doc/src/user/example1.im
index f54af6d..8ca90b6 100644
--- a/doc/src/user/example1.im
+++ b/doc/src/user/example1.im
@@ -52,6 +52,6 @@
 &ex_start
 .im  j=start-example ../../../examples/rmr_dump.cpp
 &ex_end
-&figure( Simple callback application. )
+&fig( Simple callback application. )
 &uindent
 
diff --git a/doc/src/user/example2.im b/doc/src/user/example2.im
index 90a7f51..bc1a9fc 100644
--- a/doc/src/user/example2.im
+++ b/doc/src/user/example2.im
@@ -40,6 +40,6 @@
 &ex_start
 .im  j=start-example ../../../examples/xapp_t1.cpp
 &ex_end
-&figure( Simple callback application. )
+&fig( Simple callback application. )
 &uindent
 &space
diff --git a/doc/src/user/example3.im b/doc/src/user/example3.im
index e25f03e..09d2117 100644
--- a/doc/src/user/example3.im
+++ b/doc/src/user/example3.im
@@ -30,6 +30,6 @@
 &ex_start
 .im  j=start-example ../../../examples/xapp_t2.cpp
 &ex_end
-&figure( Simple looping sender application. )
+&fig( Simple looping sender application. )
 &space
 
diff --git a/doc/src/user/jhash.im b/doc/src/user/jhash.im
index d381542..ec30b0c 100644
--- a/doc/src/user/jhash.im
+++ b/doc/src/user/jhash.im
@@ -46,7 +46,7 @@
 
     jh =  new Jhash( jstring.c_str() );
 &ex_end
-&figure(The creation of the Jhash object.)
+&fig(The creation of the Jhash object.)
 &space
 
 
@@ -85,7 +85,7 @@
 .gv fig
 .sv _fig
 &set_fref(jblob_fig:&_fig)
-&figure(Sample json with a root and too blobs.)
+&fig(Sample json with a root and too blobs.)
 
 &space
 Upon creation of the Jhash object, the &ital(root) fields, &cw(lodge_name,) &cw(member_count,) and
@@ -101,7 +101,7 @@
 .gv fig
 .sv _fig
 &set_fref(fig_blob_sample:&_fig)
-&figure(Blob selection example.)
+&fig(Blob selection example.)
 &space
 
 Currently, the selected blob must be unset in order to select a blob at the root
@@ -227,7 +227,7 @@
 &ex_end
 .gv fig
 &set_fref(array_blob_code_fig:&_fig)
-&figure(Json array containing blobs.)
+&fig(Json array containing blobs.)
 &space
 
 
@@ -250,6 +250,6 @@
 &ex_end
 .gv fig
 &set_fref(array_blob_json_fig:&_fig)
-&figure(Code to process the array of blobs.)
+&fig(Code to process the array of blobs.)
 &space
 
diff --git a/doc/src/user/user_guide.xfm b/doc/src/user/user_guide.xfm
index 6df8248..4a469f7 100644
--- a/doc/src/user/user_guide.xfm
+++ b/doc/src/user/user_guide.xfm
@@ -54,7 +54,7 @@
 
 .**  ------ major sections --------
 .im cpp_frame.im
-.im hash.im
+.im jhash.im
 
 &h1(Example Programmes)
 The following sections contain several example programmes which are written on