You are proabably right about that. However you can check
yourself. Just write a small string and add to it one char after the
other. Of course you will "tune" it e.g that you allocate in larger
chunks or the like, but on the other hand collecting a string is
probalby not a thing you do seldom, expecially now in the context of
"Web" programming. So you can probably burn a lot of time in strxxx
functions
No. I would simply not use a single of the str...() functions on that
- and I do not so in the editor I develope because when I have to
split a string in multiple ones or concatenate multiple strings inow
one single one it will be done by attaching each chare only once in
the whole run instead of wobble for- and backwards multiple times
through the same bytes.
While I read in the data I have to handle I know the maximum size I
need, setting pointers to the right areas while scanning through the
data makes quick acces to it easy and really quick while working on,
building the internal well normed output when it gets written to
external media the same occures.
getc()/putc() are a nice fuction to overcome the need to handle each
single charater by copying inside system, inside C runtime, inside
thousend of other fuctions. So there is no need to fiddle around with
...get....(), fread/frwite, fprint... and so on. getc() and when the
chare readed is not fit on the current pass unget and back to higher
level that will find it on its next get and do what is needed further.
No buffer who can overflow to will filled with unknown data, no need
to read a number of unknown bytes in unknown lenth, not even the need
of multiple ?alloc() with blind calculated size parameter.
Get the size of the file, malloc() a buffer for the size needed to get
it, malloc() the structs needed to maintain the encoded data and start
reading the file byte by byte. The runtime will internal reserve
enouth buffer space to make the read blocks/sectors/or whatever the
medium uses to organise a data stream most quickly from external
medium into memory so quick as possible.
When data has to be written the sames goes on: write byte after byte,
encode and format on the fly. There is nothing that can give you more
control over a stream and is more quickly done as to read/write on the
fly byte by byte instead to copy with or without help of a format
string from one location to another only to get it copied from there
to somewhere else only to get it copied ......
--
Tschau/Bye
Herbert
Visit
http://www.ecomstation.de the home of german eComStation
eComStation 1.2 Deutsch ist da!