Author: araujo Date: Mon May 28 05:01:42 2018 New Revision: 334275 URL: https://svnweb.freebsd.org/changeset/base/334275
Log: Update strsep(3) EXAMPLE section regards the usage of assert(3). As many people has pointed out, using assert(3) shall be not the best approach to verify if strdup(3) has allocated memory to string. Reviewed by: imp MFC after: 4 weeks. Sponsored by: iXsystems Inc. Differential Revision: https://reviews.freebsd.org/D15594 Modified: head/lib/libc/string/strsep.3 Modified: head/lib/libc/string/strsep.3 ============================================================================== --- head/lib/libc/string/strsep.3 Mon May 28 04:38:10 2018 (r334274) +++ head/lib/libc/string/strsep.3 Mon May 28 05:01:42 2018 (r334275) @@ -31,7 +31,7 @@ .\" @(#)strsep.3 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd December 5, 2008 +.Dd May 28, 2018 .Dt STRSEP 3 .Os .Sh NAME @@ -86,12 +86,12 @@ to parse a string, and prints each token in separate l char *token, *string, *tofree; tofree = string = strdup("abc,def,ghi"); -assert(string != NULL); +if (string != NULL) + while ((token = strsep(&string, ",")) != NULL) + printf("%s\en", token); -while ((token = strsep(&string, ",")) != NULL) - printf("%s\en", token); - free(tofree); +free(string); .Ed .Pp The following uses _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"