Navigation


Changeset 849:d7f940afd933 in freeDiameter


Ignore:
Timestamp:
Oct 22, 2012, 12:12:13 AM (12 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

New portability function: strndup

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/CMakeLists.txt

    r836 r849  
    6363# malloc.h ?
    6464CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)
     65
     66# strndup ? Missing on OS X
     67CHECK_FUNCTION_EXISTS (strndup HAVE_STRNDUP)
    6568
    6669
  • include/freeDiameter/freeDiameter-host.h.in

    r836 r849  
    4343#cmakedefine HAVE_AI_ADDRCONFIG
    4444#cmakedefine HAVE_CLOCK_GETTIME
     45#cmakedefine HAVE_STRNDUP
    4546
    4647#cmakedefine HOST_BIG_ENDIAN @HOST_BIG_ENDIAN@
  • include/freeDiameter/libfdproto.h

    r836 r849  
    612612#endif /* HAVE_CLOCK_GETTIME */
    613613
     614#ifndef HAVE_STRNDUP
     615char * strndup (char const *s, size_t n);
     616#endif /* HAVE_STRNDUP */
    614617
    615618
  • libfdproto/portability.c

    r837 r849  
    4646}
    4747#endif /* HAVE_CLOCK_GETTIME */
     48
     49/* Replacement for strndup for the Mac OS */
     50#ifndef HAVE_STRNDUP
     51char * strndup (char *str, size_t len)
     52{
     53        char * output;
     54        size_t outlen = strnlen (str, len);
     55        CHECK_MALLOC_DO( output = malloc (outlen + 1), return NULL );
     56
     57        output[outlen] = '\0';
     58        memcpy (output, str, outlen);
     59        return output;
     60}
     61#endif /* HAVE_STRNDUP */
Note: See TracChangeset for help on using the changeset viewer.