Changeset 32267 in project


Ignore:
Timestamp:
02/08/15 21:54:28 (5 years ago)
Author:
ecloud
Message:

set-finalize! DBusError; explicit c pointer types on the other foreign types

It seems we hopefully don't need to do anything to free a DBusMessageIter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/dbus/trunk/dbus.scm

    r32264 r32267  
    196196(define (identity a) a)
    197197
    198 (define-foreign-type error-ptr c-pointer) ;; DBusError*
    199 (define-foreign-type connection-ptr c-pointer)  ;; DBusConnection*
     198(define-foreign-type error-ptr (c-pointer "DBusError")
     199        identity
     200        (lambda (p)
     201                ; (printf "setting finalizer on error ~a~%" p)
     202                (set-finalizer! p (lambda (o)
     203                        ; (printf "finalizing error: ~a~%" o)
     204                        ((foreign-lambda void "dbus_error_free" error-ptr) o)))))
     205
     206(define-foreign-type connection-ptr (c-pointer "DBusConnection"))
     207
    200208(define-foreign-type message-ptr (c-pointer "DBusMessage")
    201209        identity
    202210        (lambda (p)
    203                 ; (printf "setting finalizer on ~a~%" p)
     211                ; (printf "setting finalizer on message ~a~%" p)
    204212                (set-finalizer! p (lambda (o)
    205                         ; (printf "===== finalizing message: ~a~%" o)
     213                        ; (printf "finalizing message: ~a~%" o)
    206214                        ((foreign-lambda void "dbus_message_unref" message-ptr) o)))))
    207215
    208 (define-foreign-type uint-ptr c-pointer)        ;; dbus_uint32_t*
    209 (define-foreign-type message-iter-ptr c-pointer)        ;; DBusMessageIter*
     216(define-foreign-type uint-ptr (c-pointer "dbus_uint32_t"))
     217
     218(define-foreign-type message-iter-ptr (c-pointer "DBusMessageIter"))
     219;; from the docs: "DBusMessageIter contains no allocated memory; it need not be freed,
     220;; and can be copied by assignment or memcpy()."
     221
    210222(define-foreign-type vtable-ptr c-pointer)      ;; DBusObjectPathVTable*
    211223
     
    748760
    749761        (set! call (lambda (context name . params)
    750                 (let* ([service (symbol->string (vector-ref context context-idx-service))]
     762                (let* ([service (symbol?->string (vector-ref context context-idx-service))]
    751763                                [msg (make-message service
    752764                                                        (symbol->string (vector-ref context context-idx-path))
Note: See TracChangeset for help on using the changeset viewer.