Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: Advice on h...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 10 of 21 Topic 24491 of 28006
Post > Topic >>

Re: Advice on how to return a list of values

by "christian.bau" <christian.bau@[EMAIL PROTECTED] > Feb 3, 2008 at 05:44 AM

The usual method goes like this:

The caller p***** a pointer to storage that it provides, and the size
of available storage. The called function provides the data, and
returns how much data is available. If the pointer passed in is a null
pointer then the callee just provides the amount of data available,
without calling anything. If the pointer passed is not null, but the
size is not enough then the callee doesn't write more data than
storage available.

That makes it quite clear what the callee has to do. For the caller,
there are two strategies: If you know an amount of data that is
usually enough, then do a call with a limited amount of local data
first; if this fails then the caller will know how much storage is
needed and will malloc it. Alternatively, if there is no reasonable
guess about the data size, pass a null pointer in the first call, then
make a second call with the storage properly allocated.
 




 21 Posts in Topic:
Advice on how to return a list of values
"Remo D." <r  2008-02-03 07:47:21 
Re: Advice on how to return a list of values
Ian Collins <ian-news@  2008-02-03 20:01:14 
Re: Advice on how to return a list of values
"Remo D." <r  2008-02-03 08:38:57 
Re: Advice on how to return a list of values
pete <pfiland@[EMAIL P  2008-02-03 06:32:31 
Re: Advice on how to return a list of values
Keith Thompson <kst-u@  2008-02-02 23:57:26 
Re: Advice on how to return a list of values
"Remo D." <r  2008-02-03 11:35:07 
Re: Advice on how to return a list of values
Paul Hsieh <websnarf@[  2008-02-03 00:33:45 
Re: Advice on how to return a list of values
"Remo D." <r  2008-02-03 11:47:21 
Re: Advice on how to return a list of values
"Bartc" <bc@  2008-02-03 12:27:46 
Re: Advice on how to return a list of values
"christian.bau"  2008-02-03 05:44:30 
Re: Advice on how to return a list of values
richard@[EMAIL PROTECTED]  2008-02-03 18:41:47 
Re: Advice on how to return a list of values
cri@[EMAIL PROTECTED] (R  2008-02-03 19:08:08 
Re: Advice on how to return a list of values
CBFalconer <cbfalconer  2008-02-03 20:55:39 
Re: Advice on how to return a list of values
Ian Collins <ian-news@  2008-02-04 16:41:32 
Re: Advice on how to return a list of values
Tim Smith <reply_in_gr  2008-02-03 23:59:00 
Re: Advice on how to return a list of values
Ian Collins <ian-news@  2008-02-04 21:53:30 
Re: Advice on how to return a list of values
"Remo D." <r  2008-02-04 12:01:22 
Re: Advice on how to return a list of values
SM Ryan <wyrmwif@[EMAI  2008-02-04 20:21:34 
Re: Advice on how to return a list of values
CBFalconer <cbfalconer  2008-02-04 17:51:38 
Re: Advice on how to return a list of values
SM Ryan <wyrmwif@[EMAI  2008-02-05 21:24:07 
Re: Advice on how to return a list of values
Michal Nazarewicz <min  2008-02-06 21:21:38 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 12:51:43 CST 2008.