LCOV - code coverage report
Current view: top level - src - free_string_array.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 9 9
Test Date: 2026-03-31 13:51:38 Functions: 100.0 % 1 1
Branches: 83.3 % 6 5

             Branch data     Line data    Source code
       1                 :             : #include "precizer.h"
       2                 :             : 
       3                 :             : /**
       4                 :             :  * @brief Free a NULL-terminated string array and reset the caller-owned pointer
       5                 :             :  *
       6                 :             :  * @param[in,out] array_ptr Pointer to the array pointer to free
       7                 :             :  *
       8                 :             :  * @note Passing `NULL` or a pointer to `NULL` is allowed
       9                 :             :  */
      10                 :        1824 : void free_string_array(char ***array_ptr)
      11                 :             : {
      12   [ +  -  +  + ]:        1824 :         if(array_ptr == NULL || *array_ptr == NULL)
      13                 :             :         {
      14                 :        1592 :                 return;
      15                 :             :         }
      16                 :             : 
      17                 :         232 :         char **array = *array_ptr;
      18                 :             : 
      19         [ +  + ]:         612 :         for(size_t i = 0; array[i] != NULL; i++)
      20                 :             :         {
      21                 :         380 :                 free(array[i]);
      22                 :         380 :                 array[i] = NULL;
      23                 :             :         }
      24                 :             : 
      25                 :         232 :         free(array);
      26                 :         232 :         *array_ptr = NULL;
      27                 :             : }
        

Generated by: LCOV version 2.0-1