On Fri, Jun 6, 2008 at 4:02 PM, Jon Paris <Jon.Paris@xxxxxxxxxxxxxx> wrote:

On 6-Jun-08, at 5:40 PM, rpg400-l-request@xxxxxxxxxxxx wrote:

I am concerned that if I use the %size value when allocating storage
that I am not giving sufficient space to the structure which could
cause issues with corrupted memory. Should I be allocating 656 to
each element of myds or 644?

Thanks for any comments on this question.

-Paul

D myds ds likeds(regex_t)
D dim(64)
D based(pMyds)

Given that you are not really using that much storage, I'm not sure
why you are bothering with dynamic memory. That said - you _must_
allocate in multiples of 656. That is how big each element is
because there is a pad of 12 bytes required at the end of each
element in order to align the following element.

You should still be able to use %Size to calculate your requirements
like so: actualSize = ( %Size(arrayname: *all) / %Elem(arrayname) )

Thanks Scott, Barbara and Jon for your explanations/responses and the
named constant tip!

-Paul

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.