7
7
#include "./macros.h"
8
8
#include "./patterns/main.h"
9
9
10
- // TODO: Documentation
10
+ /**
11
+ * @brief Frees the memory allocated for a 2D array.
12
+ *
13
+ * This function deallocates the memory used by a 2D array of characters. It iterates through each
14
+ * row, frees the memory allocated for each row, and then frees the memory allocated for the array
15
+ * of row pointers.
16
+ *
17
+ * @param arr 2D array to be destroyed.
18
+ * @param rows Number of rows in the 2D array.
19
+ * @param cols Number of columns in the 2D array.
20
+ *
21
+ * @warning Ensure that the array has been dynamically allocated and that the number of rows and
22
+ * columns are correctly specified to avoid undefined behavior.
23
+ */
11
24
void destroy2DArray (char * * arr , int rows , int cols );
12
25
13
26
/**
@@ -24,7 +37,10 @@ void destroy2DArray(char** arr, int rows, int cols);
24
37
* string as input and returns an integer. The validator function should return
25
38
* 1 if the input is valid, and 0 otherwise.
26
39
*
27
- * @return A pointer to the string entered by the user.
40
+ * @return A pointer to the string entered by the user dynamically allocated in memory.
41
+ *
42
+ * @warning Ensure to free the returned pointer after use with the appropriate deallocation
43
+ * functions to avoid memory leaks.
28
44
*/
29
45
char * getUserInputStr (char * message , char * onInvalidMessage , int strLength ,
30
46
int (* validator )(char * userInput ));
@@ -42,7 +58,20 @@ char* getUserInputStr(char* message, char* onInvalidMessage, int strLength,
42
58
*/
43
59
int isStrIn (char * str , char * arr [], int arrLength );
44
60
45
- // TODO: Documentation
61
+ /**
62
+ * @brief Initializes a 2D array of characters.
63
+ *
64
+ * This function dynamically allocates memory for a 2D array of characters with the specified number
65
+ * of rows and columns.
66
+ *
67
+ * @param rows Number of rows.
68
+ * @param cols Number of columns.
69
+ *
70
+ * @return A pointer to the 2D array of characters.
71
+ *
72
+ * @warning Ensure to free the allocated memory using appropriate deallocation functions to avoid
73
+ * memory leaks.
74
+ */
46
75
char * * new2DArray (int rows , int cols );
47
76
48
77
/**
0 commit comments