You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.4 KiB

2 years ago
1 year ago
  1. /**
  2. * @file pEp_string.h
  3. * @brief external interface for allocation and deletion of NUL-terminated char strings within the engine
  4. * @license GNU General Public License 3.0 - see LICENSE.txt
  5. */
  6. #ifndef PEP_STRING_H
  7. #define PEP_STRING_H
  8. #include <string.h>
  9. #include "dynamic_api.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /**
  14. * <!-- new_string() -->
  15. *
  16. * @brief Allocate a new string
  17. *
  18. * @param[in] src string to copy or NULL
  19. * @param[in] len length of newly created string or 0 for default
  20. *
  21. * @retval pointer to string object or NULL if out of memory
  22. * calling with str and len is equivalent to strndup()
  23. * calling with str but len=0 is equivalent to strdup()
  24. * calling with str=NULL is equivalent to calloc()
  25. *
  26. *
  27. */
  28. DYNAMIC_API char * new_string(const char *src, size_t len);
  29. /**
  30. * <!-- free_string() -->
  31. *
  32. * @brief Free memory occupied by string
  33. *
  34. * @param[in] s pointer to string to free
  35. *
  36. *
  37. */
  38. DYNAMIC_API void free_string(char *s);
  39. /**
  40. * <!-- string_dup() -->
  41. *
  42. * @brief Duplicate a string
  43. *
  44. * @param[in] src string to duplicate
  45. * @param[in] len length of newly created string or 0 for default
  46. *
  47. * @retval pointer to copy or NULL if out of memory
  48. *
  49. *
  50. */
  51. DYNAMIC_API char * string_dup(const char *src, size_t len);
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif