chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] Evicted objects


From: Tony Sidaway
Subject: [Chicken-users] Evicted objects
Date: Mon, 5 Feb 2007 23:03:58 +0000

This is the crux of it.

$ cat testevict.scm
(use lolevel)

(define (myalloc size)
 (printf "Requested ~S byte\n" size)
 (let ((obj (allocate size)))
   (printf "~S\n" obj)
   obj))

(define getmem (foreign-lambda* void ((c-string ptr)) "printf (\"ptr =
%p\\n\", ptr);"))

(define s "A string")
(define e (object-evict s myalloc))
(getmem e)

$

Notice that I'm using the optional second parameter to object-evict so
that I can print out the allocated pointer address.

When compiled and run I'd expect this program to show that the pointer
received by getmem is very close to the pointer returned by allocate
(just the same plus the size of the header used to describe the object
to Scheme, basically).

Instead I get completely different values.

$ csc testevict.scm
$ ./testevict
Requested 12 byte
#<pointer 0x806b488>
ptr = 0xbfec0864
$

My expectations are obviously wrong.

What's happening there?




reply via email to

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