Re: [avr-gcc-list] strlen() returns erroneous values

From:

Kitts

Subject:

Re: [avr-gcc-list] strlen() returns erroneous values

Date:

Sat, 4 Jun 2005 23:46:28 +0530

User-agent:

KMail/1.8

On Saturday 04 Jun 2005 1:01 am IST, Kitts wrote:
> Hi All,
>
> Are there any special considerations to take care of when using the
> function strlen()? The function does not always return the right
> values. Some times it appears to skip a NULL character and reaches
> out to the next following NULL.
>
> I am multitasking on the AVR and from the avr-libc documentation i
> found the function to have the "_ATTR_PURE_" attribute. Could this be
> the cause for the problem? What does this attribute signify anyway?
After a little fiddling around this is what i have found.
When i use the strlen() function inside another function such that its
output is the argument for the function i would get erroneous values
for strlen. When i can functions in this manner, the call stack is
probable large. The default thread stack size 0f 85 bytes was not
enough.
Either increasing the thread stack size or separating out the functions
such that only variables are directly set as arguments to the function
helped me solve this problem.
Now this leaves me with a doubt of how constant strings are managed? Are
they loaded into RAM right at startup or at the time when they are
used? Loading all constant strings to RAM at startup would
unnecessarily consume a lot of RAM.
--
Cheers!
Kitts