strlen returning -1 for a valid string

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

strlen returning -1 for a valid string

697 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NZSmartie on Mon Nov 26 20:38:34 MST 2012
Hey guys,

recently with my application, I've loaded my companies IAP Bootloader which has shifted my program up about 64KB in the flash.
I've using a LPC1758 and I'm using Red suite 4 (NXP Edition) 512K

The problem I'm having is I have a set of strings in an array, as I iterate through the array, strlen is used on all strings and passed to the UART.
after hitting the 3rd string in the array, strlen returns -1. I'm not sure why it happens. When debugging, the string is displayed in the watch without problems.
I've set up a if statement for the -1, and to print out the string using:
sprintf(UBuf,"Some how got %d from '%s'",i,ptr);

where
i = strlen(ptr);

and ptr is a string from the array.

In my serial console, i see:
Some how got -1 from ' '


Does the string functions fail if the pointers are too high in the memory?
I can't find any useful information regarding this.
When debugging, ptr = 0x318CC; and is 14 chars in length;

I'm using Redlib no-host, and I'm managing my own linker scripts

Cheers
Roman
0 Kudos
Reply
0 Replies