delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
Message-ID: | <464E15EA.DC2A59E2@yahoo.com> |
Date: | Fri, 18 May 2007 17:08:58 -0400 |
From: | CBFalconer <cbfalconer AT yahoo DOT com> |
Organization: | Ched Research http://cbfalconer.home.att.net |
X-Mailer: | Mozilla 4.75 [en] (Win98; U) |
X-Accept-Language: | en |
MIME-Version: | 1.0 |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: How to count the occurance of a character in a string? |
References: | <20070511181210 DOT GT3209 AT freenet DOT de> <f22p42$bu7$1 AT aioe DOT org> <20070512111553 DOT GO1881 AT freenet DOT de> <f24kg3$k88$1 AT aioe DOT org> <20070515164057 DOT GC1818 AT freenet DOT de> <f2f79a$1i6$1 AT aioe DOT org> <20070516160358 DOT GA20179 AT freenet DOT de> <464B3526 DOT 2080909 AT schluessler DOT org> |
Lines: | 27 |
NNTP-Posting-Date: | 18 May 2007 20:35:19 GMT |
X-Complaints-To: | abuse AT teranews DOT com |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Timo Schlüßler wrote: > ... snip ... > > char *strdup(const char *s) > { > size_t len = strlen (s) + 1; > char *result = (char*) malloc (len); > if (result == (char*) 0) > return (char*) 0; > return (char*) memcpy (result, s, len); > } > > (This is the code for the real strdup() function.) I hope not. Every one of those casts is unnecessary, and only serves to conceal errors, such as failure to #include <stdlib.h>. Besides which, there is no strdup routine in standard C. POSIX and Linux may be different. It is available under DJGPP. -- <http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt> <http://www.securityfocus.com/columnists/423> <http://www.aaxnet.com/editor/edit043.html> <http://kadaitcha.cx/vista/dogsbreakfast/index.html> cbfalconer at maineline dot net -- Posted via a free Usenet account from http://www.teranews.com
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |