By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,260 Members | 1,285 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,260 IT Pros & Developers. It's quick & easy.

Space allocation

P: n/a
Hi,

I have to write an application to compress data, which is a pointer to the
start of the data and the length of the data in bytes. When I want to
compress the data should decrease. So how do I allocate the needed space? I
had two ideas:
- Use of a vector of char
- Copy of the uncompressed file and use the space of the copy for the
copressed data.
Does anyone see another possibility? Which one is the best?

Andi
Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Andi Hotz" <an*******@adsl.li> wrote in message
news:3f*********************@news.sunrise.ch...
Hi,

I have to write an application to compress data, which is a pointer to the
start of the data and the length of the data in bytes. When I want to
compress the data should decrease. So how do I allocate the needed space? I had two ideas:
- Use of a vector of char
- Copy of the uncompressed file and use the space of the copy for the
copressed data.
Does anyone see another possibility? Which one is the best?

Andi


Well, a lot depends upon how big the data is. You say you pass a pointer to
the data and its length, so that must mean that it's in memory already. So
files are irrelevant. You can always allocate an equal amount of space,
since you know it will always be less. A vector sounds easy enough, but
possibly overkill for simple char's. Or you can just use "new char[size]"
(and later, "delete[]"). Again, though, it depends how you're doing the
compression. Are you going over the data more than once, applying multiple
compression techniques? Or is it just once through the source, creating the
destination? Perhaps you can even do the compresssion in place, not
allocating any new space at all? The algorithm you've chosen should
indicate what an appropriate method would be.

-Howard


Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.