[REBOL] Re: A collection of garbage
From: lmecir:mbox:vol:cz at: 10-Jul-2003 12:48
Hi Cyphre and Gabriele,
I changed the GET-MEM? function implementation slightly to use a "truly dynamic" local
variable.
I found out, that the crash occurs even if we don't use the cycle:
address?: function [
{get the address of a string}
s [any-string!]
] [address] [
s: make struct! [s [string!]] reduce [s]
address: make struct! [i [integer!]] none
change third address third s
address/i
]
get-mem?: func [
{get the byte from a memory address}
address [integer!]
/nts {a null-terminated string}
/part {a binary with a specified length}
length [integer!]
] [
use [m] [
address: make struct! [i [integer!]] reduce [address]
if nts [
m: make struct! [s [string!]] none
change third m third address
return m/s
]
if part [
m: head insert/dup copy [] [. [char!]] length
m: make struct! compose/deep [bin [struct! (reduce [m])]] none
change third m third address
return first reduce [third m/bin m: none]
]
m: make struct! [c [struct! [chr [char!]]]] none
change third m third address
m/c/chr
]
]
img: make image! 512x512
recycle/off ;Warning! should allocate about xxxMB of memory
get-mem?/part probe address? img length? img
get-mem?/part probe address? img length? img
recycle
get-mem?/part probe address? img length? img
-L