TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Bo Simonsen
from: andrew clarke
date: 2004-01-28 16:05:16
subject: [C] Question about external variable initialization

Tue 2004-01-27 15:42, Bo Simonsen (2:236/100) wrote to Len Philpot:

 BS> /* Precondition: A pointer to chars
 BS>    Postcondition: A pointer which is pointed to a copy of 'precondition' 
 BS>                   if !precondtion NULL is returned
 BS>    Invariant: Precondition != NULL
 BS> */

 BS> char* strdup(char* text)
 BS> {
 BS>         char* tmptext = NULL;

 BS>         if(text) /* if text is not NULL */
 BS>         {
 BS>                 tmptext = malloc(strlen(text)+1); 
 BS>                 /* allokate the lenght of text and 1 extra char for the 
 BS>                    string NULL termination */

                     if (tmptext == NULL)
                         return NULL;

 BS>                 strcpy(tmptext, text);
 BS>         }

 BS>         return tmptext;
 BS> }

-- mail{at}ozzmosis.com

--- timEd/FreeBSD 1.11.b1
* Origin: Blizzard of Ozz, Melbourne, Victoria, Australia (3:633/267)
SEEN-BY: 633/267 270
@PATH: 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.