CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

malloc returning pointer to memory used for globals ... ?!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








malloc returning pointer to memory used for globals ... ?!
PostPosted: Tue Dec 16, 2003 4:40 am     Reply with quote

Hello everyone,

After 6 hours of debugging printf pain I discovered that a call to malloc() for 16 bytes gives me a RAM address already used by some globals. Writing to the malloc()'d pointer trashes them.

By looking in the .SYM file I can see exactly what is being trashed, and printf() debugging has verified the overwrite.

Has anyone used malloc successfully in a real program? (not a toy thing like ex_malloc.c)

Another CCS bug derailment, it looks like.

Advice?
(I really do need a malloc() type functionality)

Jesse
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 16, 2003 4:26 pm     Reply with quote

One solution would be to use #reserve to reserve a large block of ram,
and then write your own malloc() routine, to let you allocate and release
blocks of that ram. I'm sure there is code for this all over the net.
Here's a post from comp.arch.embedded that has source code for it.
http://groups.google.com/groups?&selm=01bd00c1%24817a3580%24LocalHost%40rusaneanu

Edited to add:
Actually, upon searching further, I found that CCS has the source
code in stdlibm.h, which is in this folder: c:\Program Files\Picc\Drivers
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group