- demo_struct2_t *demo2;
- demo_struct1_t *demo1;
- time_t starttime = time(0);
- char *datestring = ctime(&starttime);
- void *oldheap;
-
- /* Get back the root pointer */
- demo1 = svmdb_local_get_variable_reference
- (pm->c, SVMDB_NAMESPACE_VEC, "demo1_location");
-
- /* It doesnt exist create our data structures */
- if (demo1 == 0) {
- /* If you want MP / thread safety, lock the region... */
- pthread_mutex_lock(&pm->c->db_rp->mutex);
-
- /* Switch to the shared memory region heap */
- oldheap = svm_push_data_heap (pm->c->db_rp);
-
- /* Allocate the top-level structure as a single element vector */
- vec_validate (demo1, 0);
-
- /* Allocate the next-level structure as a plain old memory obj */
- demo2 = clib_mem_alloc (sizeof (*demo2));
-
- demo1->demo2 = demo2;
- demo1->name = format (0, "My name is Ishmael%c", 0);
- demo2->string1 = format (0, "Here is string1%c", 0);
- demo2->string2 = format (0, "Born at %s%c", datestring, 0);
-
- /* Back to the process-private heap */
- svm_pop_heap(oldheap);
- pthread_mutex_unlock(&pm->c->db_rp->mutex);
-
- /*
- * Set the root pointer. Note: this guy switches heaps, locks, etc.
- * We allocated demo1 as a vector to make this "just work..."
- */
- svmdb_local_set_vec_variable (pm->c, "demo1_location",
- demo1, sizeof (demo1));
+ demo_struct2_t *demo2;
+ demo_struct1_t *demo1;
+ time_t starttime = time (0);
+ char *datestring = ctime (&starttime);
+ void *oldheap;
+
+ /* Get back the root pointer */
+ demo1 = svmdb_local_get_variable_reference
+ (pm->c, SVMDB_NAMESPACE_VEC, "demo1_location");
+
+ /* It doesnt exist create our data structures */
+ if (demo1 == 0)
+ {
+ /* If you want MP / thread safety, lock the region... */
+ pthread_mutex_lock (&pm->c->db_rp->mutex);
+
+ /* Switch to the shared memory region heap */
+ oldheap = svm_push_data_heap (pm->c->db_rp);
+
+ /* Allocate the top-level structure as a single element vector */
+ vec_validate (demo1, 0);
+
+ /* Allocate the next-level structure as a plain old memory obj */
+ demo2 = clib_mem_alloc (sizeof (*demo2));
+
+ demo1->demo2 = demo2;
+ demo1->name = format (0, "My name is Ishmael%c", 0);
+ demo2->string1 = format (0, "Here is string1%c", 0);
+ demo2->string2 = format (0, "Born at %s%c", datestring, 0);
+
+ /* Back to the process-private heap */
+ svm_pop_heap (oldheap);
+ pthread_mutex_unlock (&pm->c->db_rp->mutex);
+
+ /*
+ * Set the root pointer. Note: this guy switches heaps, locks, etc.
+ * We allocated demo1 as a vector to make this "just work..."
+ */
+ svmdb_local_set_vec_variable (pm->c, "demo1_location",
+ demo1, sizeof (demo1));