473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Space allocation

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
1 1799

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Philip Yale | last post by:
At my current workplace, whenever I check table sizes using the 'reserved' column from sysindexes, or sp_spaceused, I get a total for all user tables which exceeds the physical size of the...
5
by: lixiaoyao | last post by:
hi all I use matrix & vector function to allocate the space myself in c, typedef struct matrix_array newdata; struct matrix_array{ float **sy,*sxx; }; newdata ndata;//new data struct...
3
by: asm | last post by:
Hello all, I need your help on this problem. I wrote a little program as follows. (BTW, I worked on a new dell latitude, runing Linux kernel 2.4.19, i686). Program was compiled with gcc 3.2 ...
14
by: Otto Meijer | last post by:
Hi everyone, for one of my projects I need to figure out the size of the swap file(s) of a certain system. The problem is I need to do this on a host of platforms like: HP_UX, Solaris, Linux,...
14
by: Gattaca | last post by:
I would like to create a matrix of integers by allocating memory dynamically (malloc or calloc) because i and j are defined during execution of the program. I have got not problem to do this in...
1
by: mike | last post by:
Hi for those who can help me... I am dutch and try to use my best English. I do not know if thi is the right group to asked my question. I am bussy with makeing a wensite where people can...
3
by: David Buck | last post by:
If I have a structure as follows; typedef struct { double x; double y; int size; char text; } text; I have allocated a space of 256 bytes for some text entered. If the...
6
by: Chi | last post by:
According this http://research.microsoft.com/research/pubs/view.aspx?tr_id=841 said, if you pre-allocation space for writing , it will be much faster, but how can i do this? Thank
9
by: DataSmash | last post by:
I simply want to capture the free disc space in a variable so that I can compare changes. I'm aware of a few commands like "df -h" or "du - k", but I can't figure out how to capture those values...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.