Ticket #54412: patch-examples-libevent-client.c.diff

File patch-examples-libevent-client.c.diff, 1.2 KB (added by Schamschula (Marius Schamschula), 7 years ago)
  • examples/libevent-client.c

    old new  
    2222 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
    2323 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    2424 */
     25 
     26#ifdef __APPLE__
     27#ifndef __MAC_OS_X_VERSION_MIN_REQUIRED
     28#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
     29#include <Availability.h>
     30#else
     31#include <AvailabilityMacros.h>
     32#endif
     33#endif
     34#if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1060
     35static char * strndup (char const *s, size_t n);
     36static size_t strnlen (const char *string, size_t maxlen);
     37
     38static size_t
     39strnlen (const char *string, size_t maxlen)
     40{
     41  const char *end = memchr (string, '\0', maxlen);
     42  return end ? (size_t) (end - string) : maxlen;
     43}
     44
     45static char *
     46strndup (char const *s, size_t n)
     47{
     48  size_t len = strnlen (s, n);
     49  char *new = malloc (len + 1);
     50
     51  if (new == NULL)
     52    return NULL;
     53
     54  new[len] = '\0';
     55  return memcpy (new, s, len);
     56}
     57#endif
     58#endif
     59
    2560#ifdef __sgi
    2661#include <string.h>
    2762#define errx(exitcode, format, args...)                                        \