unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: David Pirotte <david@altosw.be>
To: Neil Jerram <neiljerram@gmail.com>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: make-c-struct and pointer->string
Date: Fri, 29 Mar 2019 05:48:40 -0300	[thread overview]
Message-ID: <20190329054840.363e42a0@capac> (raw)
In-Reply-To: <CAKuG=vsySSSf8gpRq-iHpC9p3TcnOn1bknFQNm6Yf3JfJGnQkA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1347 bytes --]

Hello Neil,

> I guess it may be GC.  I've had problems with code like
> 
>    (procedure->pointer void (lambda (...) ...) args...)
> 
> because procedure->pointer does not protect the (lambda ...) from being GC'd.
> 
> For example:
> http://git.savannah.nongnu.org/cgit/ossaulib.git/commit/?id=1d31a87b53e9375b5fdd5120b7d409e6dde6aa47
> 
> 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 work 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 str-1) (string->pointer str-2)))
$2 = #<pointer 0x55ae02e57830>
scheme@(guile-user)> (parse-c-struct $2 (list '* '*))
$3 = (#<pointer 0x55ae02f9e3c0> #<pointer 0x55ae02f8b050>)
scheme@(guile-user)> (map pointer->string $3)
$4 = ("" "`\v?\x02?U")

Cheers,
David

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-03-29  8:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-26 13:14 make-c-struct and pointer->string David Pirotte
2019-03-28 15:15 ` Amirouche Boubekki
2019-03-28 15:42   ` Neil Jerram
2019-03-29  8:48     ` David Pirotte [this message]
2019-03-29  9:46       ` David Pirotte
2019-03-29 19:08         ` Neil Jerram
2019-03-28 15:48   ` David Pirotte
2019-03-30 20:26 ` Mark H Weaver
2019-03-31 10:38   ` David Pirotte
2019-04-01  6:23     ` Mark H Weaver
2019-04-01  8:50     ` Mark H Weaver
2019-04-02 18:03       ` David Pirotte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190329054840.363e42a0@capac \
    --to=david@altosw.be \
    --cc=guile-devel@gnu.org \
    --cc=neiljerram@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).