guile-user
[Top][All Lists]
Advanced

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

Re: how to access c-array member in c-structure?


From: Taylan Ulrich Bayırlı/Kammer
Subject: Re: how to access c-array member in c-structure?
Date: Wed, 30 Mar 2016 10:03:28 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Park SungMin <address@hidden> writes:

> (let ((c-type (list int int (make-list 20000 int))))
>     (parse-c-struct
>      ((pointer->procedure
>        c-type
>        (dynamic-func "make_foo" libfoo)
>        (list int int))
>       4 11)
>      c-type))
>
> also run well…but seems less effective.(if more bigger size…2000000??) 

You could create the type object once at program startup and use it
many times.

    (define foo-type
      (list int int (make-list 2000000 int)))
    
    (define make-foo
      (pointer->procedure foo-type
                          (dynamic-func "make_foo" libfoo)
                          (list int int)))
    
    (parse-c-struct (make-foo 4 11) foo-type)
    (parse-c-struct (make-foo 12 5) foo-type)
    (parse-c-struct (make-foo 8 91) foo-type)
    ...

Taylan



reply via email to

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