Archived

This topic is now archived and is closed to further replies.

memory allocation problem

This topic is 5536 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

could anyone tell me what the problem could be if you''ve malloc()''ed a buffer, then later tries to free it with free().. but free exits the program with error code 0x3?!?.. saying something about DAMAGE: after normal block #40.. I have used the debugger and the pointer I am trying to free is exactly the same value that the corresponding malloc() call returned.. I can''t understand why this is happening.. info about exactly where malloc() stores allocation info would be appreciated too, because that would give me something to work with :-(

Share this post


Link to post
Share on other sites
you were right.. Allocating one more byte solved the problem.. or actually it did not, because the error is still there.. but it probably has something to do with one of my loops.. Am I the only one who find it pretty hard to write an RLE encoder? or am I just stupid? also could anyone post some code for their RLE encoders?.. mine is almost working.. but it is a very complex function and it could probably be done in a much better way :-)

Share this post


Link to post
Share on other sites
RLE?

  1. Look at data and determine number of consecutive identical values.

  2. Pack value and run length into token.

  3. Write token to file.

  4. If end of data stream, exit. Otherwise, return to step 1.


Interesting issues:
How do you differentiate between tokens? One solution is to use a token demarcation identifier, which should be a value that never shows up in your data stream. If you pack your tokens as a 32-bit pair of values (run length, value), then a (0,0) token could break up runs. More sophisticated schemes exist and are widely deployed.

Non-runs, ie, single token sequences or sequences for which the RLE yields no real benefit. It''s better to simply store these values as they are.

Share this post


Link to post
Share on other sites