Re: trim function dumping core
- From: Joe Wright <joewwright@xxxxxxxxxxx>
- Date: Thu, 07 Dec 2006 19:12:13 -0500
raxitsheth2000@xxxxxxxxxxx wrote:
Joe/rkk,
check following main with your ltrim/rtrim/trim/trim_all...
int main()
{
char *p=NULL;
ltrim(p);
rtrim(p);
return 0;
}
I am not sure what should be the behaviour of l/r/all trim against NULL
ptr, on my sys is Seg Fault.(I am knowing why)
Should we check ?
char* (l/r) trim (char *s)
{
if (s==NULL) return NULL;
your remaining code of ltrim/rtrim;
}
this will ensure that your trim function is stable against one more
type of Bad-Input, (like one more testcase)
Even it is more likely that program may crash, but not in
ltrim/rtrim/all_trim written by you.
any thought on this ?
--raxit sheth
String functions should behave gracefully when given strings to deal with. Even zero length strings. It is up to the caller to ensure against NULL pointers passed to string functions, IMO.
--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
.
- Follow-Ups:
- Re: trim function dumping core
- From: pete
- Re: trim function dumping core
- References:
- trim function dumping core
- From: rkk
- Re: trim function dumping core
- From: Joe Wright
- Re: trim function dumping core
- From: raxitsheth2000
- trim function dumping core
- Prev by Date: Re: sizeof operator implementation
- Next by Date: Re: trim function dumping core
- Previous by thread: Re: trim function dumping core
- Next by thread: Re: trim function dumping core
- Index(es):
Relevant Pages
|