Should I free strtok() results?

Henry Spencer henry at utzoo.uucp
Wed Apr 11 04:24:30 AEST 1990


In article <6501 at rouge.usl.edu> pcb at gator.cacs.usl.edu (Peter C. Bahrs) writes:
>The string functions that return pointers to memory, should their
>results be freed?

"String" is not a real data type in C; those functions do not return
strings, they return pointers into the strings *you* supplied as arguments.
They do not allocate any storage, and consequently it is an error to apply
free() to their results.
-- 
Apollo @ 8yrs: one small step.|     Henry Spencer at U of Toronto Zoology
Space station @ 8yrs:        .| uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list