× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Kurt Anderson wrote:
So myDynaArray_p is global? myDynaArray is local and not Static so it
would be cleaned up when the procedure ends. So the address of
myDynaArray_p would end up NULL right? Which would defeat the entire
purpose of the procedure.

myDynaArray is local -- but it's neither static nor automatic. It's based on a pointer! RPG isn't going to manage it's storage for you!! You have to manage it yourself.

so the labels "static" and "automatic" don't apply to based() data.

However, myDynaArray_p -- unless it's defined somewhere else that Lim didn't show us -- is defined in automatic storage. So you're right that the pointer itself will be reset to *NULL on subsequent calls. But, the memory that it points to is not released -- just the pointer itself is.

Since the value that was in the pointer is passed back to the caller via the piRtnListDynaArray parameter, the fact that the pointer itself is released doesn't really matter. the value of the pointer is preserved, and that's what counts.

It also doesn't matter that it's reset to *NULL, since the routine calls %alloc() right away, anyway, which will provide a new address with new storage.

So I guess I don't understand your concern, Kurt. What difference does it make whether the pointer is in automatic or static storage?


If you got around that issue, I'd say that you'd also want to pass the
number of elements, otherwise the caller has no idea how many elements
there are to access and could attempt to access an elements beyond the
memory allocated.

On that score, I totally agree.

But would rather that he stop using this technique altogether :)

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.