From a5c415d15a5ca6d35c290bc2430dcb5e812cf2ce Mon Sep 17 00:00:00 2001 From: Ryan Culpepper Date: Wed, 21 Nov 2012 00:01:35 -0500 Subject: [PATCH] change allocator wrapper to ignore #f results Supports foreign functions that either allocate or return NULL (translated to #f). --- collects/ffi/unsafe/alloc.rkt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/collects/ffi/unsafe/alloc.rkt b/collects/ffi/unsafe/alloc.rkt index 5b03678069..107e910b62 100644 --- a/collects/ffi/unsafe/alloc.rkt +++ b/collects/ffi/unsafe/alloc.rkt @@ -23,8 +23,9 @@ start-atomic (lambda () (let ([v (apply proc args)]) - (hash-set! allocated v (list d)) - (register-finalizer v deallocate) + (when v + (hash-set! allocated v (list d)) + (register-finalizer v deallocate)) v)) end-atomic)) proc))