Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #15592
| From | Miles Bader <miles@gnu.org> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Search and replace c-style strings in c++ |
| Date | 2012-04-27 05:40 +0900 |
| Message-ID | <8762cmp6q6.fsf@catnip.gol.com> (permalink) |
| References | <4f98fec4$0$3095$7b1e8fa0@news.nbl.fi> <jnb94n$6vl$2@dont-email.me> <428484582357157913.172399troplin-bluewin.ch@news.aioe.org> |
Tobias Müller <troplin@bluewin.ch> writes: >>> Returning unmanaged allocated memory from a function is a BAD >>> idea and should always be avoided. >> >> Wow, that's a bit strong. Given that the OP code is essentially C, >> this is a long accepted idiom in pure C. I totally agree that this >> is error prone and that there are better ways but always be avoided >> is a bit OTT (even if the OP code is a bit OT and should really be >> in comp.language.c is he really doesn't want to use C++). > > I think in C it is much more common to pass a target buffer as parameter > and returning the number of chars written to that buffer, like: That's the usual "ye olde" C style, but malloc'd returned buffers seem increasingly common in modern code... -miles -- "Don't just question authority, Don't forget to question me." -- Jello Biafra
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Search and replace c-style strings in c++ Mike Semko <msemko@gmail.com> - 2012-04-24 16:06 -0700
Re: Search and replace c-style strings in c++ Ian Collins <ian-news@hotmail.com> - 2012-04-25 11:16 +1200
Re: Search and replace c-style strings in c++ Mike Semko <msemko@gmail.com> - 2012-04-24 16:38 -0700
Re: Search and replace c-style strings in c++ Ian Collins <ian-news@hotmail.com> - 2012-04-25 12:08 +1200
Re: Search and replace c-style strings in c++ Mike Semko <msemko@gmail.com> - 2012-04-24 17:32 -0700
Re: Search and replace c-style strings in c++ Ian Collins <ian-news@hotmail.com> - 2012-04-25 12:35 +1200
Re: Search and replace c-style strings in c++ Mike Semko <msemko@gmail.com> - 2012-04-24 17:45 -0700
Re: Search and replace c-style strings in c++ Old Wolf <oldwolf@inspire.net.nz> - 2012-05-06 22:50 -0700
Re: Search and replace c-style strings in c++ Paavo Helde <myfirstname@osa.pri.ee> - 2012-04-24 22:58 -0500
Re: Search and replace c-style strings in c++ scott@slp53.sl.home (Scott Lurndal) - 2012-04-25 00:00 +0000
Re: Search and replace c-style strings in c++ Ian Collins <ian-news@hotmail.com> - 2012-04-25 12:11 +1200
Re: Search and replace c-style strings in c++ scott@slp53.sl.home (Scott Lurndal) - 2012-04-25 14:51 +0000
Re: Search and replace c-style strings in c++ Juha Nieminen <nospam@thanks.invalid> - 2012-04-26 07:52 +0000
Re: Search and replace c-style strings in c++ yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2012-04-26 10:47 +0000
Re: Search and replace c-style strings in c++ Juha Nieminen <nospam@thanks.invalid> - 2012-04-26 11:04 +0000
Re: Search and replace c-style strings in c++ Tobias Müller <troplin@bluewin.ch> - 2012-04-26 18:43 +0000
Re: Search and replace c-style strings in c++ Miles Bader <miles@gnu.org> - 2012-04-27 05:40 +0900
Re: Search and replace c-style strings in c++ Miles Bader <miles@gnu.org> - 2012-04-25 10:28 +0900
Re: Search and replace c-style strings in c++ Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2012-04-26 23:50 -0400
Re: Search and replace c-style strings in c++ Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2012-04-28 09:46 -0400
Re: Search and replace c-style strings in c++ "Miquel van Smoorenburg" <miquels@netscum.invalid> - 2012-05-06 20:03 +0000
csiph-web