1
0

string_dupn.c 534 B

1234567891011121314151617181920212223242526
  1. /*
  2. * string_dupn.c
  3. */
  4. #include "private.h"
  5. #include <string.h>
  6. #include <stdlib.h>
  7. /*--------------------------------------------------------- */
  8. char *
  9. lub_string_dupn(const char *string,
  10. unsigned length)
  11. {
  12. char *result=NULL;
  13. if(NULL != string)
  14. {
  15. result = malloc(length+1);
  16. if(NULL != result)
  17. {
  18. strncpy(result,string,length);
  19. result[length] = '\0';
  20. }
  21. }
  22. return result;
  23. }
  24. /*--------------------------------------------------------- */