unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Josh Datko <jbdatko@gmail.com>
To: guile-user@gnu.org
Subject: Re: segmenation fault
Date: Fri, 09 Jun 2017 10:36:08 -0600	[thread overview]
Message-ID: <1497026168.17088.6.camel@gmail.com> (raw)
In-Reply-To: <20170609121834.1eae7cf7@dell.homenet>

> On Fri, 9 Jun 2017 10:17:18 +0200
> Catonano <catonano@gmail.com> wrote:
> > 
> If you want to manipulate a scheme bytevector at the C level you can
> also look at the c-write procedure here for ideas:
> https://github.com/ChrisVine/guile-a-sync/blob/master/lib/unix_write.
> c
> 
> (As a point of detail, this procedure is only required with guile-2.0 
> -
> with guile-2.2, suspendable ports are used instead - but it shows you
> one approach to working with scheme buffers or other objects.)

When I scheme in C (lol, sounds funny), I ended up with bytevector code
like this:

size_t len = scm_c_bytevector_length (bv);
signed char * SCM_BYTEVECTOR_CONTENTS (bv);

Now, I'm pretty new at this, so the reason I'm asking it to seek
opinions on a best practice re: this thread.

The reason I write it that way is that, I think, the
scm_c_bytevector_length will throw an exception if it's not a
bytevector. This lets me be a bit lazy and not explicitly check. Then I
get the pointer to the bv.

This could just be a case of there-are-many-ways-to-do-it, but I would
have not thought to do:

void* c_buf = scm_to_pointer(scm_bytevector_to_pointer(bv, begin));

per that example so I was curious if there was an advantage or
something wrong with my thinking of how I Scheme in C :)

I'm using Guile 2.0.11 on Ubuntu.

Josh



  reply	other threads:[~2017-06-09 16:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-09  7:21 segmenation fault Catonano
2017-06-09  7:43 ` Thomas Danckaert
2017-06-09  8:00   ` Amirouche Boubekki
2017-06-09  8:17     ` Catonano
2017-06-09 11:18       ` Chris Vine
2017-06-09 16:36         ` Josh Datko [this message]
2017-06-09 20:18         ` Catonano
2017-06-11 20:56     ` Catonano
2017-06-11 22:09       ` Catonano
2017-06-09  8:42   ` Catonano

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=1497026168.17088.6.camel@gmail.com \
    --to=jbdatko@gmail.com \
    --cc=guile-user@gnu.org \
    /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).