中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-15 05:22
47,812 topics / 349,917 posts / today 0 new / 48,268 members
DOS开发编程 & 发展交流 (开发室) » How to free space occupied by a buffer in TC
Printable Version  1,069 / 6
Floor1 sunny1979 Posted 2003-11-13 00:00
初级用户 Posts 86 Credits 376
How do I free the space occupied by a buffer in TC so I can load more images? Please give me some pointers, experts!
Floor2 Loff Posted 2003-11-14 00:00
中级用户 Posts 59 Credits 286
I don't quite understand what you mean. If the space was allocated with functions like malloc or alloc, use the free function to release it. Then the space occupied by the buffer is gone, and the buffer can no longer be used, so you'd have to allocate it again. If you want to use the original buffer space, just use it directly—the new content will overwrite the old content.
Floor3 sunny1979 Posted 2003-11-18 00:00
初级用户 Posts 86 Credits 376
To the gentleman on the second reply: I did allocate the space with functions like malloc and alloc, but I can't use free to release the occupied space. If I try to use the original buffer space to display another image, it hangs. The original program is on my homepage: http://sunny1979.icpcn.com, under My Resources, image display program. Sorry to trouble you, please take a look and see what's going on! Thanks in advance!
Floor4 Loff Posted 2003-11-18 00:00
中级用户 Posts 59 Credits 286
There is no "image display program" under "My Resources" on your homepage, but there is a program called "TC loading 16-color BMP files" under "My Works". I don't know whether that's the one you mean. There were no errors during compilation, and I also got the hang you mentioned. I noticed there is a line like this near the end of the main function in your source code:
if((buffer=malloc(ff->ff_fsize))==NULL)exit(0);
I changed the malloc in it to farmalloc, and the problem seemed to be solved (I tried many times and it didn't hang). You can try changing it and see if it works. My guess is that malloc easily gets space from the DOS system area, causing the DOS system to crash, while farmalloc is more reliable.
Floor5 sunny1979 Posted 2003-11-20 00:00
初级用户 Posts 86 Credits 376
I changed the malloc in it to farmalloc, and it hung! If I don't change it, it can still run. Maybe the settings are different! It can only load this one image; if I load another one, it definitely hangs! Can you load another image too?
Floor6 Loff Posted 2003-11-20 00:00
中级用户 Posts 59 Credits 286
Try changing the compile mode to large or huge. I'm using huge


Floor7 sunny1979 Posted 2003-11-20 00:00
初级用户 Posts 86 Credits 376
Why can it only load one image?
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023