From: Ian Jackson Subject: Re: [PATCH v2-resend 11/30] libxl: ocaml: allocate a long lived libxl context. Date: Tue, 27 Aug 2013 16:38:42 +0100 Message-ID: <21020.51202.537269.496721@mariner.uk.xensource.com> References: <1377168678-25492-1-git-send-email-rob.hoes@citrix.com> <1377168678-25492-12-git-send-email-rob.hoes@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1377168678-25492-12-git-send-email-rob.hoes@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Rob Hoes Cc: ian.campbell@citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Rob Hoes writes ("[Xen-devel] [PATCH v2-resend 11/30] libxl: ocaml: allocate a long lived libxl context."): > Rather than allocating a new context for every libxl call begin to > switch to a model where a context is allocated by the caller and may > then be used for multiple calls down into the library. ... > @@ -59,6 +65,8 @@ static void log_destroy(struct xentoollog_logger *logger) > lg.logger.vmessage = log_vmessage; \ > lg.logger.destroy = log_destroy; \ > lg.logger.progress = NULL; \ > + lg.log_offset = 0; \ > + memset(&lg.log_buf,0,sizeof(lg.log_buf)); \ Is this in the wrong patch ? @@ -77,7 +85,7 @@ static char * dup_String_val(caml_gc *gc, value s) > c = calloc(len + 1, sizeof(char)); > if (!c) > caml_raise_out_of_memory(); > - gc->ptrs[gc->offset++] = c; > + if (gc) gc->ptrs[gc->offset++] = c; I don't understand this at all. Is it going to become local to call this without a gc and if so what is its function in that case ? > @@ -94,9 +102,41 @@ static void failwith_xl(char *fname, struct caml_logger *lg) > { > char *s; > s = (lg) ? lg->log_buf : fname; > + printf("Error: %s\n", fname); > caml_raise_with_string(*caml_named_value("xl.error"), s); > } I don't understand why this hunk is in this patch, either. Ian.