At 10:23 AM -0700 11/1/04, Bill Coffman wrote:
Hello,
Just getting back to parrot.

[Leo]* alloca() isn't portable and not available everywhere
[Dan] Yep. This is a gcc-ism. Use Parrot's memory allocation functions instead.


reg_alloc.c uses malloc().  I saw alloca() used in the CVS tree
earlier, but it's gone now.  What is the correct way to allocate
memory in Parrot?

That depends. If it's GC-able memory (that is, hanging off a buffer) then use Parrot_allocate or Parrot_reallocate (depending on whether you're doing a malloc or realloc). For memory you track by hand, use mem_sys_allocate, mem_sys_reallocate, and mem_sys_free. The first set are in resources.c with docs, the second in memory.c.


[Leo] * all functions should have an Interp* and a IMC_Unit* argument to allow
[Leo] reentrancy. I.e. all state should be in the unit structure.

I'm not quite sure I understand this.  I get that each function call
has (interpreter,unit) as parameters.  But why is this?  Parrot
handles interrupts, I understand, so this probably has something to do
with interrupt processing.  Does this also mean that there should be
no other data structures, except those pointed to by interpreter or
unit?

To allocate anything in parrot you need an interpreter pointer. (To do a lot of other stuff too) It's worth slinging them around everywhere, since it's a big pain to add them all in after the fact, piecemeal. (Been there, done that :)


[Dan] I'd like the code issues cleaned up before it gets committed.

I want to fix the memory leak, which involves rewriting a few
functions.  This might go fast, or it could become difficult.  It's
probably best to send an intermediate patch that has the code issues
fixed.  That way we can maximize code review, and make sure I'm
writing parrot compliant code.

Cool. And you've got that monstrosity of mine to test on :) -- Dan

--------------------------------------it's like this-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to