From: Mathias N. <sdc...@gm...> - 2004-01-31 01:14:36
|
Moin, just two more hints on malloc ()... - check whether malloc () returns a valid pointer - allocated memory must be "given back" by free () uchar *full: full = malloc (strlen (file) +1); if (full != NULL) { /* do something */ free (full); } bis die Tage... Mathias >Hi Sebastian, > >no, that's no bug in the string library. >That's just an error in your source-code. > >strcpy () [or any other strXXX function) will not allocate >memory for any given parameter. >You'll have to do that beforehand. >Also, strXXX functions won't check any of the parameters >(for NULL-pointers or size). > >You must assure, that >- memory for the target string is allocated >- the target memory is large enough to hold the copied string > >You can allocate memory as a local variable by > > uchar full [25]; /* hopefully 25 bytes ar enough! */ > >or of course dynamically by > > uchar *full: > full = malloc (strlen (file) +1); > >In both cases you must take into account, that memory is tight >on the average embedded system! > > >bis die Tage... > Mahias > > > >>Hello all! >> >>Is there a known bug with "strcpy" from the "string"-library? The >>following code just seems to crash on a DS80C400: >> >>char fat_create(uchar *file) { >> >> uchar *path = NULL; >> uchar *name = NULL; >> uchar *full = NULL; >> uchar *part = NULL; >> uchar *last = NULL; >> >> strcpy(full, file); >> printstring((xdata*)"Copied"); >> >> part = strtok(full, (xdata*)"/"); >> last = part; >> printstring((xdata*)"Tokenized"); >> >> >> while (part != NULL) { >> part = strtok(NULL, (xdata*)"/"); >> if (part != NULL) { >> strcat(path, (xdata*)"/"); >> strcat(path, last); >> last = part; >> } else { >> name = part; >> } >> } >>} >> >>The last thing I get is a message prompted just before calling this >>function and the "Copied" message won't show up. >> >> >>TIA, >> >>Sebastian >> >> >>------------------------------------------------------- >>The SF.Net email is sponsored by EclipseCon 2004 >>Premiere Conference on Open Tools Development and Integration >>See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. >>http://www.eclipsecon.org/osdn >>_______________________________________________ >>Sdcc-user mailing list >>Sdc...@li... >>https://lists.sourceforge.net/lists/listinfo/sdcc-user >> > > > |
From: Frieder F. <fri...@we...> - 2004-02-01 11:51:46
|
>> printstring((xdata*)"Copied"); > Interesting cast :-> What do you intend? > The string is stored in code space, a cast to xdata makes no sense at all. If the device uses unified memory (f.e. 32k flash memory is mapped into xdata AND code memory from 0x0000 to 0x7fff, 32k sram above 0x8000 in xdata memory) this allows for shorter code (printstring can avoid generic pointers). Frieder |
From: Tom <to...@im...> - 2004-05-20 09:56:25
|
Hi, There is a fully functional simulators for 8051 / 80390 and PIC processors at http://www.dcd.pl/asoft.php. It works with SDCC compiler basic HEX output formats. However it is a company, but they are giving simulators free of charge for any purpose (commercial, home, educational). It also includes hardware debugger for their 8051/80390/PIC chips. I hope that this link will be useful. Cheers, Tom. |
From: Dave M. <mc...@ne...> - 2004-05-20 22:55:50
|
On May 20, 2004, at 5:57 AM, Tom wrote: > There is a fully functional simulators for 8051 / 80390 and PIC > processors at > http://www.dcd.pl/asoft.php. > > It works with SDCC compiler basic HEX output formats. > > However it is a company, but they are giving simulators free of charge > for any > purpose (commercial, home, educational). It also includes hardware > debugger > for their 8051/80390/PIC chips. Hmm, looks like Windows only. :-( -Dave -- Dave McGuire "PC users only know two 'solutions'... Cape Coral, FL reboot and upgrade." -Jonathan Patschke |