K
Kevin
I have a routine that is copying chunks of a super large string into a
new order. It is acting as a message translator. For certain source
messages, the string routines seem to stop, and the cpu utilization
goes to 99%. When I attach to the process, the program is always on
either strchr or strlen.
Here is a snippet of code demonstrating these symptoms:
/* Look for space in input to break line upon*/
pcSrcCharLoc = pcAdjustedInput;
while (pcSrcCharLoc < pcAdjustedInput + lWidthData)
{
pcSpacePointer = strchr(pcSrcCharLoc, ' ');
tLocOfSpace = pcSpacePointer - pcSrcCharLoc;
... processing of string between pcSrcCharLoc and pcSpacePointer
- a sprintf of pcSrcCharLoc onto pcDestCharLoc for length tLocOfSpace
plus some logging wrapped in if's.
pcSrcCharLoc += tLocOfSpace;
}
pcAdjustedInput is a pointer to a string of the field being copied,
which has had extra spaces removed. The pointer was alloc'd by the
routine that copied the string removing the spaces. The string is
null terminated. LWidthData is the strlen of pcAdjustedInput.
What will happen is on the first run through, the first substring (a
word) is processed, and then the program stops on the next strchr, and
the CPU utilization goes to 99%.
Any hints, ideas, or someone pointing out the obvious would be greatly
appreciated.
Thanks
Kevin
new order. It is acting as a message translator. For certain source
messages, the string routines seem to stop, and the cpu utilization
goes to 99%. When I attach to the process, the program is always on
either strchr or strlen.
Here is a snippet of code demonstrating these symptoms:
/* Look for space in input to break line upon*/
pcSrcCharLoc = pcAdjustedInput;
while (pcSrcCharLoc < pcAdjustedInput + lWidthData)
{
pcSpacePointer = strchr(pcSrcCharLoc, ' ');
tLocOfSpace = pcSpacePointer - pcSrcCharLoc;
... processing of string between pcSrcCharLoc and pcSpacePointer
- a sprintf of pcSrcCharLoc onto pcDestCharLoc for length tLocOfSpace
plus some logging wrapped in if's.
pcSrcCharLoc += tLocOfSpace;
}
pcAdjustedInput is a pointer to a string of the field being copied,
which has had extra spaces removed. The pointer was alloc'd by the
routine that copied the string removing the spaces. The string is
null terminated. LWidthData is the strlen of pcAdjustedInput.
What will happen is on the first run through, the first substring (a
word) is processed, and then the program stops on the next strchr, and
the CPU utilization goes to 99%.
Any hints, ideas, or someone pointing out the obvious would be greatly
appreciated.
Thanks
Kevin