Summary: | ASTERISK-04532: [patch] Cannot compile on Freebsd after introduction of strndup() in channel.c | ||
Reporter: | Chris Ochs (snacktime) | Labels: | |
Date Opened: | 2005-07-06 17:02:36 | Date Closed: | 2011-06-07 14:03:19 |
Priority: | Major | Regression? | No |
Status: | Closed/Complete | Components: | Core/General |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) 20050708__freebsd_strndup__2.diff.txt ( 1) 20050709__freebsd_strndup__addl.diff.txt ( 2) 20050709__freebsd_strndup__take3.diff.txt ( 3) patch.txt | |
Description: | Trying to compile HEAD on Freebsd 5.4 is broken, because Freebsd (and I think Solaris also) do not have strndup(). Attached is a patch which reverts to using strdup(). I don't see any real difference in using strndup() versus strdup() in this particular case, but not being a C programmer I could easily be missing something. | ||
Comments: | By: Yuri (ys) 2005-07-07 05:11:40 May be as follow: #if defined(__FreeBSD__) buf = strdup((char *)f->data); /* dup and break */ #else buf = strndup((char *)f->data, f->datalen); /* dup and break */ #endif By: Kevin P. Fleming (kpfleming) 2005-07-07 18:36:00 The point of using strndup there is that the f->data array may not be null-terminated, so we need to copy only the relevant portion of the array. Whatever solution we use must continue to provide the same semantics. By: Tilghman Lesher (tilghman) 2005-07-08 09:38:51 Try installing devel/libstrfunc out of the ports tree and add an additional #include <strfunc.h> into the source file instead. You'll also need to add -lstrfunc into the Makefile in the LIBS section. That should be sufficient to get strndup() on FreeBSD. By: Tilghman Lesher (tilghman) 2005-07-08 13:12:12 Patch uploaded which should be sufficient for FreeBSD. By: Malcolm Davenport (mdavenport) 2005-07-08 17:46:40 Thanks :) By: Chris Ochs (snacktime) 2005-07-08 20:21:15 The patch almost works, but not quite. The strfunc library is installed in /usr/local/lib, so.. +LIBS+=-lcrypto -lstrfunc should be... +LIBS+=-lcrypto -lstrfunc -L$(CROSS_COMPILE_TARGET)/usr/local/lib And also.. +#ifndef __STRFUNC_H__ should be +#ifndef STRFUNC_H By: Tilghman Lesher (tilghman) 2005-07-09 07:36:17 Uploaded additional patch. Note that libstrfunc changed their header file define in the last major release. Should apply cleanly over the version already in CVS. By: Malcolm Davenport (mdavenport) 2005-07-09 08:11:51 Changes made in CVS. Okay to resolve? By: Tilghman Lesher (tilghman) 2005-07-09 08:16:00 It appears you lost a closing parenthesis in channel.c By: Malcolm Davenport (mdavenport) 2005-07-09 11:29:22 Got it. By: Tilghman Lesher (tilghman) 2005-07-09 12:23:30 Ooops. One more 2 character fix. By: Tilghman Lesher (tilghman) 2005-07-09 16:31:53 Committed by anthm. By: Digium Subversion (svnbot) 2008-01-15 15:40:25.000-0600 Repository: asterisk Revision: 6064 U trunk/Makefile U trunk/channel.c ------------------------------------------------------------------------ r6064 | malcolmd | 2008-01-15 15:40:25 -0600 (Tue, 15 Jan 2008) | 2 lines Bug ASTERISK-4532 - Require libstrfunc for FreeBSD. Thanks Corydon ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=6064 By: Digium Subversion (svnbot) 2008-01-15 15:40:26.000-0600 Repository: asterisk Revision: 6065 U trunk/Makefile U trunk/channel.c ------------------------------------------------------------------------ r6065 | malcolmd | 2008-01-15 15:40:26 -0600 (Tue, 15 Jan 2008) | 2 lines Bug ASTERISK-4532 - Take two ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=6065 |