From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Josh Datko Newsgroups: gmane.lisp.guile.user Subject: Re: segmenation fault Date: Fri, 09 Jun 2017 10:36:08 -0600 Message-ID: <1497026168.17088.6.camel@gmail.com> References: <20170609.094329.1861758562085707445.post@thomasdanckaert.be> <20170609121834.1eae7cf7@dell.homenet> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1497026202 13415 195.159.176.226 (9 Jun 2017 16:36:42 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 9 Jun 2017 16:36:42 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Jun 09 18:36:35 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dJMtm-00034p-EI for guile-user@m.gmane.org; Fri, 09 Jun 2017 18:36:34 +0200 Original-Received: from localhost ([::1]:55762 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJMtr-0007Ij-Jx for guile-user@m.gmane.org; Fri, 09 Jun 2017 12:36:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJMtV-0007Id-B7 for guile-user@gnu.org; Fri, 09 Jun 2017 12:36:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJMtR-00059y-Ah for guile-user@gnu.org; Fri, 09 Jun 2017 12:36:17 -0400 Original-Received: from mail-it0-x235.google.com ([2607:f8b0:4001:c0b::235]:36895) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dJMtR-00059c-5a for guile-user@gnu.org; Fri, 09 Jun 2017 12:36:13 -0400 Original-Received: by mail-it0-x235.google.com with SMTP id m47so659428iti.0 for ; Fri, 09 Jun 2017 09:36:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:date:in-reply-to:references:mime-version :content-transfer-encoding; bh=t+6SSaanLti3Udnm639vKsz1a4yNr3uAYQlR/TvpLQg=; b=K20a2bpt78FaZWbRuNNeUn0Bli7dFxuWckz2sw7JGJkSyX2jABfUCJn/WC3STuLXik hyAT1s29B9F9Ss9OURwtS0uAVSj78InFx7F2uGqrJtOhmCvMhCkTGeeUcA0Il0P5LRkw oZ1ZqVbjUf3/C9f8jgKs0N+MzLslmMxC3VSqR3uzdKs9JcisepwR9XL9gjeyui0MF6/G hR9w0g+kDe3qfxDYobZKQSX3t5aXwANMhwAsyhIC8BHRtD5P5MrPFdanZwwCh5ayvEfr nlJT4UxC+jcofPgObFKCskVjX86zoOUZ4ALoQ2oQArBGdvPRL8KAC6JPuD11IvL42PAx e1Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=t+6SSaanLti3Udnm639vKsz1a4yNr3uAYQlR/TvpLQg=; b=geCqiYZkKb1z98koNRYFzJW91DUNPK1Eqf//kK7sYSzP2RnPsvtmHgHXIjOdvQHXGL wgbfkbzP/AT+5WHCiIE0truvyMXOcyV9St8O0CU3YoALvNCGRYDprVbzSm2+zGLb36jA pffKMdkr4N1gRBBax10WsXT+4CsSfDG8fX7Ry6qcPo5LfpZ6zNhQYJV/QZTdrj+Kc8bG ERX27Tgz9T7xpVIOm9IJJ0kEOZ/9JRjrcBiUVX8QBJvH0o8MM3QHCtzM/IHBIAB25XZn MXsR//RkWwud0jcy8sJkjKRAxFet5SlSQlqn2f3+6Yg5tflBa9trVUIpE4sin1a431O0 m/6Q== X-Gm-Message-State: AODbwcANtD6WNw62uaHQyOvYcuFRipB8YRtmqY1EVjD5BtvfdpMp4gCf OQI8BKjBVZF9xcOInTo= X-Received: by 10.36.91.212 with SMTP id g203mr370856itb.7.1497026170784; Fri, 09 Jun 2017 09:36:10 -0700 (PDT) Original-Received: from magrathea (c-71-196-160-121.hsd1.co.comcast.net. [71.196.160.121]) by smtp.googlemail.com with ESMTPSA id b72sm64683itd.5.2017.06.09.09.36.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Jun 2017 09:36:09 -0700 (PDT) In-Reply-To: <20170609121834.1eae7cf7@dell.homenet> X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c0b::235 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:13787 Archived-At: > On Fri, 9 Jun 2017 10:17:18 +0200 > Catonano 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