Should I free strtok() results?

Bjorn Engsig bengsig at oracle.nl
Wed Apr 11 00:17:31 AEST 1990


Article <6501 at rouge.usl.edu> by pcb at gator.cacs.usl.edu (Peter C. Bahrs) says:
|The string functions that return pointers to memory, should their
|results be freed?
All string functions that are part of ANSI C (see K&R 2, appendix B3) do
not allocate any memory, and therefore nothing should be freed (strtok is
among these).

Please note, that strdup is not among these (why isn't it in ANSI C?), and
that you should free the memory returned by it when it is no longer in use.
-- 
Bjorn Engsig,	Domain:		bengsig at oracle.nl, bengsig at oracle.com
		Path:		uunet!mcsun!orcenl!bengsig



More information about the Comp.lang.c mailing list