On Mon, 7 Jul 2008, Andrew Whitworth via RT wrote:
> On Thu Mar 13 18:06:21 2008, doughera wrote:
> > I don't know if those calculations are still correct, now that strings
> > are not "bufferlike".
>
> Most of the memory management code uses a cast to (Buffer *) or (PObj *)
> to test a generic object's flags field. So long as a particular item's
> flag field can be found in this method, the alignment of the rest of the
> item should neither be assumed nor expected. To that end, I would say
> that strings are indeed "bufferlike" because you can cast them to a
> buffer to test for the flags field.
>
> Maybe it's worthwhile for us to test the offset values of the flags
> field for each type of item (string, buffer, pobj, pmc, stack_chunk_t)
> to ensure they are properly aligned and interchangable, as the memory
> system treats them.
The casting you refer to should be fine, since all the structures in
question are isomorphic (at least for the first few elements). So
casting to (Buffer *) to find the flags is fine.
The particular calculations I was referring to are ones that involve using
sizeof(Buffer), when the objects in question no longer have a "Buffer".
In terms of testing offsets, yes, I could see generating a file that was
compiled and run at Configure.pl time that verified that structures look
like we think they look. I suspect it would pass just fine. My worry was
more related to memory constructs that are not explicit structures, but
that are managed "by hand" (e.g. the refcount in src/resources.c).
--
Andy Dougherty [EMAIL PROTECTED]
Dept. of Physics
Lafayette College, Easton PA 18042