Skip to content

Instantly share code, notes, and snippets.

@danking
Created March 18, 2014 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danking/9631801 to your computer and use it in GitHub Desktop.
Save danking/9631801 to your computer and use it in GitHub Desktop.
#lang racket
(require ffi/unsafe
ffi/unsafe/custodian)
(define n 0)
(define (foo)
(define 100bytes (malloc 100 'raw))
(define uid n)
(set! n (add1 n))
(register-custodian-shutdown 100bytes
(lambda (x)
(log-error "hello there ~a" uid)
(free x)))
100bytes)
(let ((x (foo))
(y (foo)))
0)
(define bar (foo))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment