Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Message-ID | <4E7D05DE.4960@mindspring.com> (permalink) |
|---|---|
| Date | 2011-09-23 18:19 -0400 |
| From | pete <pfiland@mindspring.com> |
| Organization | PF |
| Newsgroups | comp.lang.c |
| Subject | Re: evaluate a generic swap function |
| References | <fae63bac-e9c4-48e2-9c4f-e0269b2b3f2c@w8g2000yqi.googlegroups.com> <slrnj7nobn.124n.usenet-nospam@guild.seebs.net> <11027611.3262.1316798819548.JavaMail.geo-discussion-forums@yqjc18> <0.cd4cbe9b01c698079f35.20110923183607BST.87y5xfw48o.fsf@bsb.me.uk> <2208063.1130.1316800191576.JavaMail.geo-discussion-forums@yqih9> |
Nelu wrote: > Yes, but memory for the tmp variable in your example is allocated/deallocated every time you enter/exit the block of code. The static variable is allocated at the start of the program and successive calls to the function will not need to allocate more memory. Same with the thread local variables as long as you reuse the same threads, no? If you want instead, to have a single memory reservation for multiple function calls, and also to have thread safety, then you could copy the technique used for the renentrant varieties of strtok, commonly available on many systems and usually known as either strtok_r or strtokr. You add another parameter to the swap function with the address of the scratch memory. The scratch memory is reserved in the calling function and can have any kind of duration. -- pete
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
evaluate a generic swap function Stanley Rice <heconghui@gmail.com> - 2011-09-20 06:51 -0700
Re: evaluate a generic swap function jacob navia <jacob@spamsink.net> - 2011-09-20 16:01 +0200
Re: evaluate a generic swap function jt@toerring.de (Jens Thoms Toerring) - 2011-09-20 14:29 +0000
Re: evaluate a generic swap function jacob navia <jacob@spamsink.net> - 2011-09-20 21:13 +0200
Re: evaluate a generic swap function jt@toerring.de (Jens Thoms Toerring) - 2011-09-20 20:30 +0000
Re: evaluate a generic swap function Keith Thompson <kst-u@mib.org> - 2011-09-20 17:05 -0700
Re: evaluate a generic swap function gazelle@shell.xmission.com (Kenny McCormack) - 2011-09-21 15:45 +0000
Re: evaluate a generic swap function Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-09-21 09:33 -0700
Re: evaluate a generic swap function jacob navia <jacob@spamsink.net> - 2011-09-21 19:17 +0200
Re: evaluate a generic swap function gazelle@shell.xmission.com (Kenny McCormack) - 2011-09-21 17:34 +0000
Re: evaluate a generic swap function Jack Foot <foot@dev.null.invalid> - 2011-09-21 18:12 +0000
Re: evaluate a generic swap function Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-09-20 07:33 -0700
Re: evaluate a generic swap function ImpalerCore <jadill33@gmail.com> - 2011-09-20 08:26 -0700
Re: evaluate a generic swap function pete <pfiland@mindspring.com> - 2011-09-20 23:10 -0400
Re: evaluate a generic swap function "BartC" <bc@freeuk.com> - 2011-09-20 22:20 +0100
Re: evaluate a generic swap function jacob navia <jacob@spamsink.net> - 2011-09-20 23:23 +0200
Re: evaluate a generic swap function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-09-20 23:07 +0100
Re: evaluate a generic swap function Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-20 21:15 -0400
Re: evaluate a generic swap function Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-09-21 03:17 -0700
Re: evaluate a generic swap function Gene <gene.ressler@gmail.com> - 2011-09-21 02:40 -0700
Re: evaluate a generic swap function Seebs <usenet-nospam@seebs.net> - 2011-09-23 01:46 +0000
Re: evaluate a generic swap function Nelu <tandauioan@gmail.com> - 2011-09-23 10:26 -0700
Re: evaluate a generic swap function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-09-23 18:36 +0100
Re: evaluate a generic swap function Nelu <tandauioan@gmail.com> - 2011-09-23 10:49 -0700
Re: evaluate a generic swap function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-09-23 20:18 +0100
Re: evaluate a generic swap function Nelu <tandauioan@gmail.com> - 2011-09-23 12:54 -0700
Re: evaluate a generic swap function James Kuyper <jameskuyper@verizon.net> - 2011-09-23 16:43 -0400
Re: evaluate a generic swap function Nelu <tandauioan@gmail.com> - 2011-09-23 13:49 -0700
Re: evaluate a generic swap function James Kuyper <jameskuyper@verizon.net> - 2011-09-23 17:44 -0400
Re: evaluate a generic swap function Nelu <tandauioan@gmail.com> - 2011-09-23 18:04 -0700
Re: evaluate a generic swap function Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-24 13:52 -0800
Re: evaluate a generic swap function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-09-23 21:46 +0100
Re: evaluate a generic swap function Nelu <tandauioan@gmail.com> - 2011-09-23 13:59 -0700
Re: evaluate a generic swap function Seebs <usenet-nospam@seebs.net> - 2011-09-26 22:59 +0000
Re: evaluate a generic swap function pete <pfiland@mindspring.com> - 2011-09-23 18:19 -0400
Re: evaluate a generic swap function Nelu <tandauioan@gmail.com> - 2011-09-23 16:36 -0700
csiph-web