[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] How to convert c-pointer to nonnull-c-string
From: |
Felix |
Subject: |
Re: [Chicken-users] How to convert c-pointer to nonnull-c-string |
Date: |
Sat, 02 Jul 2011 13:49:11 +0200 (CEST) |
From: Santosh Rajan <address@hidden>
Subject: [Chicken-users] How to convert c-pointer to nonnull-c-string
Date: Sat, 2 Jul 2011 15:08:33 +0530
> I have a c-pointer to a C buf and buf length. Buffer sizes may be large so I
> cant use the stack. I pass a c-pointer and int length from C to the
> callback.
If the string is zero-terminated, you can use
(##sys#peek-c-string POINTER 0)
If it isn't or may contain zeros, then try this:
(use lolevel)
(define (extract-string ptr len)
(let ((buf (make-string len)))
(move-memory! ptr buf len)
buf))
cheers,
felix