[comp.unix.aux] strdup

marcelo@deadzone.uucp (Marcelo Gallardo) (06/01/91)

	When compiling a program (that I didn't write) I end up with...

undefined               first referenced
 symbol                     in file
strdup                          allocate.o

	Well I've figured out that A/UX doesn't have strdup (at least I
	can't find it). Is there anything that I can do? I guess it's
	obvious by now that my knowledge of C is limited.

-- 
Marcelo Gallardo			marcelo%deadzone@princeton.edu
Test and Evaluation Specialist		...!princeton!deadzone!marcelo
Princeton University			marcelo@sparcwood.princeton.edu
Advanced Technologies and Applications		(609) 258-5661

ron@afsg.apple.com (Ron Flax) (06/02/91)

In article <1991Jun1.071530.10961@deadzone.uucp> marcelo@deadzone.uucp (Marcelo Gallardo) writes:
>	Well I've figured out that A/UX doesn't have strdup (at least I
>	can't find it). Is there anything that I can do? I guess it's
>	obvious by now that my knowledge of C is limited.

Try this...

#ifdef STRDUP_MISSING
char *malloc ();
char *strcpy ();

/* Return a newly allocated copy of string S;
   return 0 if out of memory. */

char *
strdup (s)
     char *s;
{
  char *p;

  p = malloc ((unsigned) (strlen (s) + 1));
  if (p)
    strcpy (p, s);
  return p;
}
#endif


--
Ron Flax
ron@afsg.apple.com	
Apple Federal Systems Group

marcelo@deadzone.uucp (Marcelo Gallardo) (06/03/91)

>In article <1991Jun1.071530.10961@deadzone.uucp> marcelo@deadzone.uucp (Marcelo Gallardo) writes:
>>	Well I've figured out that A/UX doesn't have strdup (at least I
>>	can't find it). Is there anything that I can do? I guess it's
>>	obvious by now that my knowledge of C is limited.

	I'd like to thanks everyone that posted/emailed the code for me.
	The program(s) compiled and everything is working.

	You know as much as everyone complains about what A/UX
	lacks/needs, one thing it has going for it is support. Withing a
	matter of hours, I had three people from Apple email the proper
	code to stick in. Note that that was just from Apple folks, and
	not including the rest of the A/UX community that reads c.u.aux.

	Once again, thanks everyone.

-- 
Marcelo Gallardo			marcelo%deadzone@princeton.edu
Test and Evaluation Specialist		...!princeton!deadzone!marcelo
Princeton University			marcelo@sparcwood.princeton.edu
Advanced Technologies and Applications		(609) 258-5661