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



>
>  Is there a 'proper' solution to writing functions that must return an
>  arbitrarily large buffer?

I generally do it the same way that the various APIs / C-runtime / etc
routines do it.

I have the caller pass me both input and output buffers, which they've
allocated themselves, along with lengths for each.  Then, as much data as
possible is placed in the output buffer -- if that doesn't fit, then
I return an error.   (Or an escape message "Receiver Value too small to
hold result" hehe)

Maybe even include documentation that says "the maximum return buffer size
is 3 times the size of the input buffer" so that the user knows that when
he's passing 1000 bytes in, he needs 3000 bytes for the output.

At any rate, this seems to pretty much be the standard.   I've seen other
ways of doing it (such as having the procedure allocate the right amount
of memory, or using a static return buffer that simply gets reused with
every call) but these methods seem more awkward to me (and are usually the
APIs that get deprecated)

HTH


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.