]> xenbits.xensource.com Git - xcp/xen-api-libs.git/commitdiff
Those functions are of use outside of the original context, and nested functions
authorMatthias Goergens <Matthias.Goergens@citrix.com>
Thu, 17 Jun 2010 21:16:18 +0000 (22:16 +0100)
committerMatthias Goergens <Matthias.Goergens@citrix.com>
Thu, 17 Jun 2010 21:16:18 +0000 (22:16 +0100)
aren't really idiomatic C anyway.

Signed-off-by: Matthias Goergens <matthias.goergens@citrix.com>
camldm/camldm_stubs.c

index 929cea65f419c2ad83418af0cb5cc203e178565c..ea20dd5c4982dffe67c9327d041bbabd91e68b1f 100644 (file)
@@ -238,39 +238,45 @@ void camldm_mknod(value path, value mode, value major, value minor)
   CAMLreturn0;
 }
 
+
+/* Helper functions for camldm_ls */
+
+#define none Val_int(0)
+#define Tag_some Val_int(0)
+
+value some (value content) {
+  CAMLparam1 (content);
+  CAMLlocal1 (result);
+  result = caml_alloc (1, Tag_some);
+  Store_field (result, 0, content);
+  CAMLreturn (result);
+};
+value cons (value car_value, value cdr_value) {
+  CAMLparam2 (car_value, cdr_value);
+  CAMLlocal1 (cell);
+  
+  const int car = 0;
+  const int cdr = 1;
+  cell = caml_alloc (2, Tag_cons);
+  Store_field (cell, car, car_value);
+  Store_field (cell, cdr, cdr_value);
+  
+  CAMLreturn (cell);
+};
 /*
-  May leak memory.  who knows?  (Does the c function (_process_all)
+  camldm_ls may leak memory.  Who knows?  (Does the c function (_process_all)
   where I copied this from (dmsetup.c) care about memory?  dmsetup
-  exits shortly after executing it.  After testing: It does not seem
-  to leak.  Probably "dm_task_destroy(dmt);" is doing some cleaning
-  up.
+  exits shortly after executing it, anyway.
+  
+  After testing: It does _not_ seem to leak.  Probably
+  "dm_task_destroy(dmt);" is doing some cleaning up.
 */
-#define none Val_int(0)
-#define Tag_some Val_int(0)
 value camldm_ls()
 {
   CAMLparam0 ();
   CAMLlocal1 (list);
   
-  value some (value content) {
-    CAMLparam1 (content);
-    CAMLlocal1 (result);
-    result = caml_alloc (1, Tag_some);
-    Store_field (result, 0, content);
-    CAMLreturn (result);
-  };
-  value cons (value car_value, value cdr_value) {
-    CAMLparam2 (car_value, cdr_value);
-    CAMLlocal1 (cell);
-
-    const int car = 0;
-    const int cdr = 1;
-    cell = caml_alloc (2, Tag_cons);
-    Store_field (cell, car, car_value);
-    Store_field (cell, cdr, cdr_value);
-    
-    CAMLreturn (cell);
-  };
+
 
   struct dm_names *names;
   struct dm_task *dmt;