Re: ? free()

new topic     » goto parent     » topic index » view thread      » older message » newer message

Greg Haberek wrote:
> The interpreter knows this as an atom, not a pointer. It is your job
> to set the atom to zero if you require this. Chances are that you're
> using this pointer in a routine somewhere, so it is freed out of
> memory anyway.

Actually, the interpreter doesn't know what the context of the varaible is.
It knows that the variable is atomic, and therefore, it requires that the
value of it, be a numeric value that is within the Atomic range, as defined
in the documentation.

The same applies sequences, and integers.  However, with sequences, it 
basically becomes the point, of it requiring to be a container array, where
any data may be placed in it.  As far as Euphoria is concerned, it doesn't
care what is in it, as long as it's a value that can pass the type check,
and it can return to a expression.  Expression being mathmatical expression,
variable re-assignment, or passing to a routine declared within the scope of
the program instance.

The only thing that actually makes it a memory address, is that it actually
points to memory, that has been allocated by the Euphoria interpreter, or
points to memory that has been allocated within the program's memory space.
This meaning, that C/C++ Functions in a DLL can allocate memory, but it
allocates the memory within the Program's memory space, and the address
returned, is allways valid for that instance of the program.

This is why you can pass memory pointers between programs, cause they are
never the same between two diffrent instances.  And any attempt to read or
write memory outside the memory space of the program itself, will result in
machine level errors.

But when it comes down to it, in the end, Euphoria really has no clue as to
what the relivence of the data being stored in a variable is.  It keeps it's
own stack of memory addresses that it has allocated, for freeing when the
interpreter finishes executing the instructions.  Also note, that C/C++ 
functions that allocate memory, are never seen by the Euphoria Interpreter.
So therefore, has no idea that they are allocated, and does not keep track of
them.

Mario Steele
http://enchantedblade.trilake.net
Attaining World Dominiation, one byte at a time...

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu