On Friday, May 11, 2012 22:00:01 Cristian Rodríguez wrote:
El 11/05/12 15:06, David C. Rankin escribió:
Guys,
I need a bit of help. I've tried to follow the example after wchar_t * wcscat
that explains why using mempcpy is better than using strcat or wcscat, but I run into a segmentation fault attempting to use the suggested mempcpy replacement. The code in libc.html (Ver: 2.15) is shown below. I had to add the declaration for 's' to get past an undefined error (should have told me something right then).
char * concat (const char *str, ...) {
va_list ap; size_t allocated = 100; char *result = (char *) malloc (allocated);
if (result != NULL)
{
char *newp; char *wp; const char *s;
^^^^^^^^^^^^^^^^^^
Yes, there is this oversight also in the example code...
I'm going to change this in the glibc manual for glibc 2.16.
result = concat( myS1, myS2, myS3 );
^^ here here, missing sentinel ... should say.
concat( myS1, myS2, myS3, NULL );
It's even in the example code: /* @r{This function concatenates arbitrarily many strings. The last} @r{parameter must be @code{NULL}.} */ -- Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg) GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org