WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] use new gc functions to deep copy structu

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] use new gc functions to deep copy structure and only free once the gc
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 13 Aug 2010 02:15:26 -0700
Delivery-date: Fri, 13 Aug 2010 02:19:16 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Stefano Stabellini <sstabellini@xxxxxxxxxxxxx>
# Date 1281450715 -3600
# Node ID 4ca72970c246accf648953b5d0d3be7515305b1b
# Parent  65d61829f2315446631cb7e83177561b93327dab
use new gc functions to deep copy structure and only free once the gc

Signed-off-by: Vincent Hanquez <vincent.hanquez@xxxxxxxxxxxxx>
---
 tools/ocaml/libs/xl/xl_stubs.c |   25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)

diff -r 65d61829f231 -r 4ca72970c246 tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c    Tue Aug 10 15:31:37 2010 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c    Tue Aug 10 15:31:55 2010 +0100
@@ -63,18 +63,38 @@ void log_destroy(struct xentoollog_logge
                failwith_xl("cannot init context", &lg);
 
 #define FREE_CTX()  \
+       gc_free(&gc); \
        libxl_ctx_free(&ctx)
 
 static void * gc_calloc(caml_gc *gc, size_t nmemb, size_t size)
 {
        void *ptr;
        ptr = calloc(nmemb, size);
+       if (!ptr)
+               caml_raise_out_of_memory();
+       gc->ptrs[gc->offset++] = ptr;
        return ptr;
 }
 
 static char * dup_String_val(caml_gc *gc, value s)
 {
-       return String_val(s);
+       int len;
+       char *c;
+       len = caml_string_length(s);
+       c = calloc(len + 1, sizeof(char));
+       if (!c)
+               caml_raise_out_of_memory();
+       gc->ptrs[gc->offset++] = c;
+       memcpy(c, String_val(s), len);
+       return c;
+}
+
+static void gc_free(caml_gc *gc)
+{
+       int i;
+       for (i = 0; i < gc->offset; i++) {
+               free(gc->ptrs[i]);
+       }
 }
 
 void failwith_xl(char *fname, struct caml_logger *lg)
@@ -349,9 +369,6 @@ value stub_xl_domain_make(value info)
 
        FREE_CTX();
 
-       free(c_info.xsdata);
-       free(c_info.platformdata);
-
        CAMLreturn(Val_int(domid));
 }
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] use new gc functions to deep copy structure and only free once the gc, Xen patchbot-unstable <=