Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Eric Sosman <esosman@ieee-dot-org.invalid> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Passing an integer to a function that accepts a void pointer |
| Date | 2011-05-13 23:30 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <iqkt2k$kc8$1@dont-email.me> (permalink) |
| References | (2 earlier) <iqedfc$77o$1@nnrp.ngi.it> <iqfj33$dnr$1@dont-email.me> <iqh6a9$s7e$1@nnrp.ngi.it> <iqi3q2$ao1$1@dont-email.me> <iqk6rv$r1j$1@nnrp.ngi.it> |
On 5/13/2011 5:12 PM, pozz wrote:
> Il 13/05/2011 04:07, Eric Sosman ha scritto:
>>> malloc() and free() are not present in my embedded system. I have to use
>>> only static allocation.
>>
>> malloc() is absent but printf() is present? It's possible,
>> certainly, but seems unlikely if not downright perverse.
>
> Hmmm..., I haven't a big experience in C programming on embedded
> systems, but I worked on some environments. Except some (and not all)
> 8-bit microcontrollers, they had sprintf() but not dynamical allocation
> mechanisms.
I'm not disputing your observation, just remarking that it
seems an odd choice on the implementor's part. The *printf() suite
usually turns out to be a rather large amount of code, even if it's
limited just to sprintf() and doesn't do actual output. The malloc()
package is quite small by comparison, and it seems weird that an
implementor would do all the hard work of providing *printf() but
shy away from the much simpler malloc().
Hmm: One reason to omit malloc() might be that the embedded
system has its own un-malloc()-like memory management API. If so,
perhaps you could use it instead.
>> Anyhow, implementing a quick-and-dirty malloc() work-alike
>> based on a static array shouldn't take anyone more than an hour.
>
> Maybe it is possible (indeed I'm interested to have a look to some
> working implementations), but I think static allocation in embedded
> systems could be sufficient for most of all the work.
Maybe I misread you somewhere along the line, but I thought you
were worried about the lifetime of the data item referenced by the
callback function's pointer argument. If static allocation works for
your scenario, fine. But if you've got a variable and hard-to-predict
number of these callbacks being registered at run-time, you'll very
likely find yourself in need of an allocation whose lifetime is neither
infinite (static) nor tied to a scope (auto).
--
Eric Sosman
esosman@ieee-dot-org.invalid
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Passing an integer to a function that accepts a void pointer pozz <pozzugno@gmail.com> - 2011-05-11 03:01 -0700
Re: Passing an integer to a function that accepts a void pointer Tom St Denis <tom@iahu.ca> - 2011-05-11 03:52 -0700
Re: Passing an integer to a function that accepts a void pointer pete <pfiland@mindspring.com> - 2011-05-11 08:10 -0400
Re: Passing an integer to a function that accepts a void pointer pozz <pozzugno@gmail.com> - 2011-05-11 18:28 +0200
Re: Passing an integer to a function that accepts a void pointer Shao Miller <sha0.miller@gmail.com> - 2011-05-11 22:10 -0500
Re: Passing an integer to a function that accepts a void pointer pozz <pozzugno@gmail.com> - 2011-05-12 19:44 +0200
Re: Passing an integer to a function that accepts a void pointer Shao Miller <sha0.miller@gmail.com> - 2011-05-12 14:16 -0400
Re: Passing an integer to a function that accepts a void pointer pozz <pozzugno@gmail.com> - 2011-05-12 21:21 +0200
Re: Passing an integer to a function that accepts a void pointer Shao Miller <sha0.miller@gmail.com> - 2011-05-12 16:05 -0400
Re: Passing an integer to a function that accepts a void pointer pozz <pozzugno@gmail.com> - 2011-05-13 23:39 +0200
Re: Passing an integer to a function that accepts a void pointer Dr Nick <3-nospam@temporary-address.org.uk> - 2011-05-14 09:41 +0100
Re: Passing an integer to a function that accepts a void pointer Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-12 22:07 -0400
Re: Passing an integer to a function that accepts a void pointer pozz <pozzugno@gmail.com> - 2011-05-13 23:12 +0200
Re: Passing an integer to a function that accepts a void pointer Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-13 23:30 -0400
Re: Passing an integer to a function that accepts a void pointer Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-11 04:03 -0700
Re: Passing an integer to a function that accepts a void pointer Heikki Kallasjoki <see@end.of.message.invalid> - 2011-05-11 13:03 +0000
Re: Passing an integer to a function that accepts a void pointer Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-11 06:46 -0700
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-11 08:24 -0700
Re: Passing an integer to a function that accepts a void pointer Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-11 08:44 -0700
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-11 08:58 -0700
Re: Passing an integer to a function that accepts a void pointer gazelle@shell.xmission.com (Kenny McCormack) - 2011-05-11 17:38 +0000
Re: Passing an integer to a function that accepts a void pointer Kenneth Brody <kenbrody@spamcop.net> - 2011-05-11 14:57 -0400
Re: Passing an integer to a function that accepts a void pointer Paul N <gw7rib@aol.com> - 2011-05-11 14:06 -0700
Re: Passing an integer to a function that accepts a void pointer Michael Press <rubrum@pacbell.net> - 2011-05-12 13:59 -0700
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-12 14:12 -0700
Re: Passing an integer to a function that accepts a void pointer Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-12 15:27 -0700
Re: Passing an integer to a function that accepts a void pointer Seebs <usenet-nospam@seebs.net> - 2011-05-12 22:37 +0000
Re: Passing an integer to a function that accepts a void pointer Ian Collins <ian-news@hotmail.com> - 2011-05-13 10:41 +1200
Re: Passing an integer to a function that accepts a void pointer Shao Miller <sha0.miller@gmail.com> - 2011-05-12 17:57 -0500
Re: Passing an integer to a function that accepts a void pointer Ian Collins <ian-news@hotmail.com> - 2011-05-13 11:05 +1200
Re: Passing an integer to a function that accepts a void pointer Seebs <usenet-nospam@seebs.net> - 2011-05-12 23:19 +0000
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-12 16:32 -0700
Re: Passing an integer to a function that accepts a void pointer Shao Miller <sha0.miller@gmail.com> - 2011-05-12 19:13 -0500
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-12 18:18 -0700
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-12 16:18 -0700
Re: Passing an integer to a function that accepts a void pointer Tobias Blass <tobiasblass@gmx.net> - 2011-05-13 08:24 +0000
Re: Passing an integer to a function that accepts a void pointer Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-13 01:33 -0700
Re: Passing an integer to a function that accepts a void pointer Seebs <usenet-nospam@seebs.net> - 2011-05-13 08:36 +0000
Re: Passing an integer to a function that accepts a void pointer "madamemandm@yahoo.com" <madamemandm@yahoo.com> - 2011-05-13 07:08 -0700
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-12 15:59 -0700
Re: Passing an integer to a function that accepts a void pointer Seebs <usenet-nospam@seebs.net> - 2011-05-11 21:46 +0000
Re: Passing an integer to a function that accepts a void pointer Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-12 00:56 -0700
Re: Passing an integer to a function that accepts a void pointer Ian Collins <ian-news@hotmail.com> - 2011-05-12 20:06 +1200
Re: Passing an integer to a function that accepts a void pointer Heikki Kallasjoki <see@end.of.message.invalid> - 2011-05-12 08:59 +0000
Re: Passing an integer to a function that accepts a void pointer Ian Collins <ian-news@hotmail.com> - 2011-05-13 10:39 +1200
Re: Passing an integer to a function that accepts a void pointer Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-12 06:51 -0400
Re: Passing an integer to a function that accepts a void pointer Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-12 04:08 -0700
Re: Passing an integer to a function that accepts a void pointer Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-12 07:33 -0400
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-12 07:58 -0700
Re: Passing an integer to a function that accepts a void pointer gazelle@shell.xmission.com (Kenny McCormack) - 2011-05-12 15:23 +0000
Re: Passing an integer to a function that accepts a void pointer Shao Miller <sha0.miller@gmail.com> - 2011-05-12 13:36 -0400
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-12 12:03 -0700
Re: Passing an integer to a function that accepts a void pointer Seebs <usenet-nospam@seebs.net> - 2011-05-12 15:57 +0000
Re: Passing an integer to a function that accepts a void pointer Michael Press <rubrum@pacbell.net> - 2011-05-12 14:14 -0700
Re: Passing an integer to a function that accepts a void pointer Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-12 22:20 -0400
Re: Passing an integer to a function that accepts a void pointer Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-05-14 02:39 +0100
Re: Passing an integer to a function that accepts a void pointer Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-11 07:37 -0400
Re: Passing an integer to a function that accepts a void pointer James Kuyper <jameskuyper@verizon.net> - 2011-05-11 09:42 -0400
Re: Passing an integer to a function that accepts a void pointer Datesfat Chicks <datesfat.chicks@gmail.com> - 2011-05-11 11:53 -0400
Re: Passing an integer to a function that accepts a void pointer Fred <fred.l.kleinschmidt@boeing.com> - 2011-05-11 10:44 -0700
Re: Passing an integer to a function that accepts a void pointer Datesfat Chicks <datesfat.chicks@gmail.com> - 2011-05-12 07:58 -0400
Re: Passing an integer to a function that accepts a void pointer Dr Nick <3-nospam@temporary-address.org.uk> - 2011-05-11 21:27 +0100
csiph-web