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



Scott Klement wrote:
The caller doesn't need to know the exact number of elements ahead of time... it just needs to know the maximum number of elements that it is willing to handle. The procedure can figure out the number of elements and pass that information back (in my example, it used the return value to do that)

I don't have too many occasions to worry about this, but do you have a preferred way to handle the case where the caller hasn't (or can't) allocate enough storage to hold all of the results?

One of the methods I've seen system APIs use it to return both the byte count of what was actually returned, as well as the number of bytes that could have been returned if there were enough space. The consumer can therefore call the API once with no memory provided for return values, then allocate precisely as much memory as is necessary to receive the entire returned structure. I can see where this might not be the best strategy if the called procedure needs to do a lot of heavy processing before it can know how much data will be returned.

- Adam

PS - sorry if this is drifting too much from your original question Lim, but I hope it has been useful to you as it has been for me.

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.