From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18431 invoked by alias); 30 Mar 2010 16:32:06 -0000 Received: (qmail 18422 invoked by uid 22791); 30 Mar 2010 16:32:05 -0000 X-SWARE-Spam-Status: No, hits=0.8 required=5.0 tests=BAYES_50,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from corp01.sj.mozilla.com (HELO mail.mozilla.com) (63.245.208.141) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 30 Mar 2010 16:32:00 +0000 Received: from mail.mozilla.com (mail.mozilla.com [10.2.72.15]) by mail.mozilla.com (Postfix) with ESMTP id 760BF17FC313; Tue, 30 Mar 2010 09:31:56 -0700 (PDT) Date: Tue, 30 Mar 2010 16:32:00 -0000 From: Dan Witte To: Tom Dalling Cc: libffi-discuss@sourceware.org Message-ID: <1999959644.62586.1269966716377.JavaMail.root@cm-mail03.mozilla.org> In-Reply-To: <1792165289.62557.1269966359890.JavaMail.root@cm-mail03.mozilla.org> Subject: Re: shallow copying in ffi_prep_cif MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact libffi-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libffi-discuss-owner@sourceware.org X-SW-Source: 2010/txt/msg00074.txt.bz2 ----- "Tom Dalling" wrote: > Is this is the intended behaviour? I just assumed that ffi_prep_cif > and ffi_prep_closure_loc would do a deep copy. Yeah, you need to keep them both alive for the lifetime of the closure. I remember reading about this in the README, or the info page, or something -- does it not specify? > Also, when it comes to freeing the memory, is there anything wrong > with doing the following? > > free(closure->cif->arg_types); > free(closure->cif); > ffi_closure_free(closure); Nope, assuming you malloc'ed closure->cif->arg_types and closure->cif. :) Note that you would also need to free any FFI_TYPE_STRUCT ffi_types that you created. Dan