瀏覽代碼

Some doxygen docs for faux/str/str.c file

Serj Kalichev 4 年之前
父節點
當前提交
e1662c85a3
共有 1 個文件被更改,包括 15 次插入7 次删除
  1. 15 7
      faux/str/str.c

+ 15 - 7
faux/str/str.c

@@ -1,5 +1,9 @@
 /** @file str.c
- * About this file2
+ * @brief String related functions
+ *
+ * This file implements some often used string functions.
+ * Some functions are more portable versions of standard
+ * functions but others are original ones.
  */
 
 #include <stdlib.h>
@@ -8,23 +12,27 @@
 #include "faux/ctype.h"
 #include "faux/str.h"
 
+/* TODO: Are that vars erally needed? */
 const char *lub_string_esc_default = "`|$<>&()#;\\\"!";
 const char *lub_string_esc_regex = "^$.*+[](){}";
 const char *lub_string_esc_quoted = "\\\"";
 
+
 /** @brief Free the memory allocated for the string.
  *
  * Safely free the memory allocated for the string. You can use NULL
  * pointer with this function. POSIX's free() checks for the NULL pointer
- * but not all systems do so.
+ * but not all systems do so. Function uses address of string pointer as an
+ * argument to NULLify pointer after freeing.
  *
- * @param [in] ptr Pointer to allocated string
+ * @param [in] str Address of string pointer
  */
-void lub_string_free(char *ptr)
-{
-	if (!ptr)
+void faux_str_free(char **str) {
+
+	if (!*str)
 		return;
-	free(ptr);
+	free(*str);
+	*str = NULL;
 }