Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!ulysses!cjc From: cjc@ulysses.att.com (Chris Calabrese) Newsgroups: comp.lang.c Subject: Re: Should I free strtok() results? Summary: pointer does not mean malloc Message-ID: <12767@ulysses.att.com> Date: 10 Apr 90 12:58:20 GMT References: <6501@rouge.usl.edu> Organization: AT&T Bell Laboratories, Murray Hill Lines: 19 In article <6501@rouge.usl.edu>, pcb@gator.cacs.usl.edu (Peter C. Bahrs) writes: > The string functions that return pointers to memory, should their > results be freed? These functions don't use the malloc library routines unless they explicitly say so in the man page. Strtok, in particular, uses the original string you pass it as its scratch buffer. That's why the man page says that it modifies the original string. Most of the other string library routines do something similar. For instance, strcat cats the second string onto the end of the first string - no internal buffer used here either. -- Name: Christopher J. Calabrese Brain loaned to: AT&T Bell Laboratories, Murray Hill, NJ att!ulysses!cjc cjc@ulysses.att.com Obligatory Quote: ``Anyone who would tell you that would also try and sell you the Brooklyn Bridge.''