strdup() "need source"

Chip Salzenberg chip at ateng.com
Fri Jun 16 01:55:25 AEST 1989


According to rl at sssphx.UUCP (Rod Longhofer):
>I am trying to compile big banner on a unix-pc, SYSV 3.5 and
>need the function strdup() if someone would be so kind to send
>it to me it would be appreciated..

Easier done than said...

	/*
	 * strdup()
	 * Duplicate a string in malloc'd memory and return the
	 * address of the duplicate, or NULL if memory exhausted.
	 */
	char *
	strdup(s)
	char *s;
	{
		char *p;

		if (s == NULL
		 || (p = malloc(strlen(s) + 1)) == NULL)
			return NULL;
		(void) strcpy(p, s)
		return p;
	}

-- 
You may redistribute this article only to those who may freely do likewise.
Chip Salzenberg         |       <chip at ateng.com> or <uunet!ateng!chip>
A T Engineering         |       Me?  Speak for my company?  Surely you jest!



More information about the Unix-pc.general mailing list