Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #15366
| From | @Jeff-Relf.Me |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Best Way to Handle Unknown Data Sizes? |
| Date | 2012-04-13 16:04 -0700 |
| Organization | Glorb Internet Services, http://www.glorb.com |
| Message-ID | <Jeff-Relf.Me@2012_Apr.13^4.04^PM> (permalink) |
| References | <MPG.29f25082df0f84119896fd@news.eternal-september.org> |
<PRE>
char* Up⋅To⋅LF( char *B⁰ ) {
// From (B⁰), return a string up to,
// but not including, any LineFeed ( 10 ).
//
// If possible, rewrite this using a temporary heap;
// so the heap can be destroyed,
// instead of calling free() and/or realloc().
static int Sz⋅Buff = 1024 ; static char *B¹ ; char *LF; int Len;
if ( LF = strchr( B⁰, 10 ), !LF ) // Do nothing.
return B⁰ ;
if ( Len = LF - B⁰ + 1, Len > Sz⋅Buff )
// Grow the buffer.
B¹ = (char*)realloc( B¹, Sz⋅Buff = Len );
else if ( !B¹ )
// Create the buffer.
B¹ = (char*)malloc( Sz⋅Buff );
sprintf( B¹, "%.*s", --Len, B⁰ ); return B¹; }
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Best Way to Handle Unknown Data Sizes? mrc2323@cox.net (Mike Copeland) - 2012-04-13 15:03 -0700
Re: Best Way to Handle Unknown Data Sizes? Ian Collins <ian-news@hotmail.com> - 2012-04-14 10:21 +1200
Re: Best Way to Handle Unknown Data Sizes? copx <copx@gazeta.pl> - 2012-04-14 00:38 +0200
Re: Best Way to Handle Unknown Data Sizes? Paavo Helde <myfirstname@osa.pri.ee> - 2012-04-13 17:39 -0500
Re: Best Way to Handle Unknown Data Sizes? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-04-13 22:42 +0000
Re: Best Way to Handle Unknown Data Sizes? red floyd <no.spam.here@its.invalid> - 2012-04-13 16:44 -0700
Best Way to Handle Unknown Data Sizes? @Jeff-Relf.Me - 2012-04-13 16:04 -0700
Best Way to Handle Unknown Data Sizes? @Jeff-Relf.Me - 2012-04-13 17:16 -0700
Re: Best Way to Handle Unknown Data Sizes? Ian Collins <ian-news@hotmail.com> - 2012-04-14 12:20 +1200
csiph-web