[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: segmenation fault

From: Josh Datko
Subject: Re: segmenation fault
Date: Fri, 09 Jun 2017 10:36:08 -0600

> On Fri, 9 Jun 2017 10:17:18 +0200
> Catonano <address@hidden> 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:
> 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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]