In the future, when 10K parts come up, I'm going to rewrite malloc in the following way: - The memory above 2K (5K and 8K in 16xx devices) will be called '.heap'. - Compiler itself wont be allowed to allocate memory there without user's intrusion. - malloc()'s bottom will be heap's bottom, which will be calculated as a .heap bottom + numb of user allocated bytes there. - malloc() calls for any other devices will return zero.
suggestions? cheers, ~d On Tuesday 18 November 2003 02:52, Chris Liechti wrote: > Robert Seczkowski wrote: > > snprintf doesn't work as snprintf(buffer,10," %2s ",string). > > It does nothing. > > it works for me. that snippet (with appropriate init, not shown): > > char buffer[80]; > snprintf(buffer, sizeof(buffer), "number: %d string: %s", 1234,"hello"); > puts(buffer); > > outputs over the serial port: > """ > number: 1234 string: hello > """ > > > Also malloc reserves begining of .noinit section for heap storage > > whereas compiler doesn't know about it and variables declared to be in > > .noinit section are overitten! > > i usualy dont use malloc.. but i did a quick test: > > i haev a global: > int global; > > and locals in main(): > char * xa; > char * xb; > > //init snipped > > xa = malloc(10); > xb = malloc(10); > printf("xa: 0x%04x\n", xa); > printf("xb: 0x%04x\n", xb); > printf("global: 0x%04x\n", &global); > > output: > xa: 0x020e > xb: 0x021a > global: 0x020a > > looks fine, xa starts after the global, ad xb starts exactly 12 bytes > later. so malloc seems to have some overhead, but it works. > and just to be sure: > > memset(xa, 0, 10); > memset(xb, 0, 10); > snprintf(xb, 10, "%d %d", 9876, 543); > snprintf(xa, 10, "%d %d", 1234, 567); > puts(xa); > puts(xb); > > outputs: > """ > 1234 567 > 9876 543 > """ > > all compiled with CFLAGS = -mmcu=${CPU} -O2 -Wall -g > cvs version of libc, some weeks old msp430-gcc 3.2.3 > > chris > > > > ------------------------------------------------------- > This SF. Net email is sponsored by: GoToMyPC > GoToMyPC is the fast, easy and secure way to access your computer from > any Web browser or wireless device. Click here to Try it Free! > https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl > _______________________________________________ > Mspgcc-users mailing list > Mspgcc-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mspgcc-users -- /***************************************************************** ("`-''-/").___..--''"`-._ (\ Dimmy the Wild UA1ACZ `6_ 6 ) `-. ( ).`-.__.`) State Polytechnical Univ. (_Y_.)' ._ ) `._ `. ``-..-' Radio-Physics Departament _..`--'_..-_/ /--'_.' ,' Saint Petersburg, Russia (il),-'' (li),' ((!.-' +7 (812) 5403923, 5585314 *****************************************************************/