> The bit that stops it compiling on Solaris is the implementation of 
> vasprintf()
> in utils.c - as far as I can see, it's only used once, in cli.c

And in res_agi.c

> It didn't want to compile because the varargs stuff seemed to be completely
> wrong for solaris.

Yes. it's very broken in several places.  It has a memory leak also.
I've fixed and tested it.

> But, whatever combination of tmp size and the '20' in the first vsnprintf,
> it always coredumps when it runs at the moment. I'm not a varargs expert, so
> I got a bit bogged down in trying to fix it.

It's not obvious to me why you get the core dump, but you are on the
right track.  It turns out Solaris 9 and below implement SUSv2 (Single
Unix Specification) and Solaris 10 implements SUSv3, and the semantics
of vsnprintf have changed between the two versions.  The following
code compiles and executes on Solaris 9/10 x86/sparc.  I will submit a
formal patch in a few minutes:

int vasprintf(char **strp, const char *fmt, va_list ap)
{
        int size;
        va_list ap2;
        char s;

        *strp = NULL;
        va_copy(ap2, ap);
        size = vsnprintf(&s, 1, fmt, ap2);
        va_end(ap2);
        *strp = malloc(size + 1);
        if (!*strp)
                return -1;
        vsnprintf(*strp, size + 1, fmt, ap);
        free(*strp);

        return size;
}
_______________________________________________
Asterisk-Dev mailing list
Asterisk-Dev@lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-dev
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Reply via email to