× 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.



Bruce,

I could see more of a use for it so I don't need to keep track of how much
space I've allocated to a pointer but I can let the system do it. That way,
I don't need to keep REALLOC-ing memory unless I've run out:

if %mem( MYPtr ) < MemNeeded;
MyPtr = %realloc( MyPtr : MemNeeded );
endif;

Having said all that, I assume that the hit from a REALLOC is typically
pretty low anyway, insofar as I assume (again) that, where possible, REALLOC
will simply allocate additional memory at the end of the existing
allocation. That being the case, and given your point below, if you specify
a 10 byte allocation, obviously the system will allocate a minimum of 16
bytes, to allow for boundary alignment (or is it 64 bytes?). However, does
the system typically/always allocate *more* than the minimum, to minimize
any future hit due to potential REALLOCs? Does the compiler take note of the
use of REALLOC in an RPG program and increase any initial allocation?

Just interested :-)

Rory

On Fri, Jun 20, 2008 at 4:49 AM, Bruce Vining <bvining@xxxxxxxxxxxxxxx>
wrote:

Rory,

I don't see any reliable way for you to access and use the allocation
size.

I suspect in one case what you really want is the size initally requested
for an explicit allocation -- but there are many cases where the size
requested is not necessarily equal to the size actually allocated by the
system. An allocation request of 10 bytes where say 64 bytes was actually
allocated wouldn't buy you much if you wanted a value of 10 returned. And
this is assuming the very restricted scenario where storage was explicitly
allocated by the calling program and you're being passed the initial byte of
the allocation.

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.