From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: David Pirotte Newsgroups: gmane.lisp.guile.devel Subject: Re: make-c-struct and pointer->string Date: Fri, 29 Mar 2019 05:48:40 -0300 Message-ID: <20190329054840.363e42a0@capac> References: <20190326101419.340081fc@capac> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/Pa8J4/XZ/N.zBAOwB5v57A2"; protocol="application/pgp-signature" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="185015"; mail-complaints-to="usenet@blaine.gmane.org" Cc: guile-devel To: Neil Jerram Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Mar 29 09:49:10 2019 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h9nCH-000lya-Gm for guile-devel@m.gmane.org; Fri, 29 Mar 2019 09:49:09 +0100 Original-Received: from localhost ([127.0.0.1]:48787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9nCG-0007FK-Eo for guile-devel@m.gmane.org; Fri, 29 Mar 2019 04:49:08 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:47896) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9nBz-0007Ex-BY for guile-devel@gnu.org; Fri, 29 Mar 2019 04:48:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h9nBx-0005vO-IK for guile-devel@gnu.org; Fri, 29 Mar 2019 04:48:51 -0400 Original-Received: from maximusconfessor.all2all.org ([79.99.200.102]:43730) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h9nBx-0005us-9L for guile-devel@gnu.org; Fri, 29 Mar 2019 04:48:49 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by maximusconfessor.all2all.org (Postfix) with ESMTP id B16861BE010C; Fri, 29 Mar 2019 09:48:47 +0100 (CET) Original-Received: from maximusconfessor.all2all.org ([127.0.0.1]) by localhost (maximusconfessor.all2all.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 51Tkaq8QmCgd; Fri, 29 Mar 2019 09:48:47 +0100 (CET) Original-Received: from capac (unknown [179.210.18.152]) by maximusconfessor.all2all.org (Postfix) with ESMTPSA id D22F81BE010B; Fri, 29 Mar 2019 09:48:46 +0100 (CET) In-Reply-To: X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 79.99.200.102 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:19867 Archived-At: --Sig_/Pa8J4/XZ/N.zBAOwB5v57A2 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hello Neil, > I guess it may be GC. I've had problems with code like >=20 > (procedure->pointer void (lambda (...) ...) args...) >=20 > because procedure->pointer does not protect the (lambda ...) from being G= C'd. >=20 > For example: > http://git.savannah.nongnu.org/cgit/ossaulib.git/commit/?id=3D1d31a87b53e= 9375b5fdd5120b7d409e6dde6aa47 >=20 > I wonder if there's a similar problem here with the string->pointer data. Thanks for your help! Following your explanation and example, I tried this and thought it would w= ork then, but it also failed: GNU Guile 2.2.4.1-cdb19 Copyright (C) 1995-2017 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guile-user)> ,use (system foreign) scheme@(guile-user)> (define str-1 "Hello") scheme@(guile-user)> (define str-2 "there!") scheme@(guile-user)> (make-c-struct (list '* '*) (list (string->pointer st= r-1) (string->pointer str-2))) $2 =3D # scheme@(guile-user)> (parse-c-struct $2 (list '* '*)) $3 =3D (# #) scheme@(guile-user)> (map pointer->string $3) $4 =3D ("" "`\v?\x02?U") Cheers, David --Sig_/Pa8J4/XZ/N.zBAOwB5v57A2 Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEhCJlRZtBM3furJHe83T9k6MFetcFAlyd2+gACgkQ83T9k6MF etefjAgA2C9jemz/AmWDfz6uyDuQPXgx1GLrnMoFJgp5G68V4bA/KKXcaLdwTLtk Y3YwLaEVwaDieRENH/t8FzR0XxphTZqvZ+o/jaeeMGJ/9xKgJgDGZGNuqe2MXFM6 nhW2ltjVqUYaydqQfTrfAi2eAor2mDhxYG9+ONFlE/VDKEdAiFa+pN6/v+UmCkku KBEsNSHhdRqRDnAgmkBovvQNXtPE+BRaUzH7dLWogX420qwD3tzwpUtqCttzC8lu xpCRAWOxG+NL+T9Yv7M+ZMTm763JR8cGgfIK/mI7aOE2K/9FCF28iEnESJrcAUyz iHbdtAXfEvNdjOd8Aa9nHFzpZs5t/w== =85mS -----END PGP SIGNATURE----- --Sig_/Pa8J4/XZ/N.zBAOwB5v57A2--