[H-GEN] malloc() causing a segfault

Martin Pool mbp at linuxcare.com.au
Thu Aug 31 20:31:01 EDT 2000


On Thu, Aug 31, 2000 at 02:29:37PM +1000, Byron Ellacott wrote:
> char *ltrim(char *i)
> {
>     char *o = i;
>     while (isspace(*i++));
>     while (*o++ = *i++);
>     return o;
> }

In the case where there is no whitespace it seems a little redundant
to copy the whole string over itself.  I'd make it a void function and
add an if(o!=i).

-- 
Martin Pool
Polishing the door
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: <http://lists.humbug.org.au/pipermail/general/attachments/20000901/3f891929/attachment.sig>


More information about the General mailing list