LCOV - code coverage report
Current view: top level - libs/mem/src - mem_delete.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 92.6 % 27 25
Test Date: 2026-03-01 04:31:48 Functions: 100.0 % 1 1
Branches: 72.2 % 18 13

             Branch data     Line data    Source code
       1                 :             : #include "mem.h"
       2                 :             : 
       3                 :        8734 : Return memory_delete(memory *memory_structure)
       4                 :             : {
       5                 :             :         /* Status returned by this function through provide()
       6                 :             :            Default value assumes successful completion */
       7                 :        8734 :         Return status = SUCCESS;
       8                 :             : 
       9         [ -  + ]:        8734 :         if(memory_structure == NULL)
      10                 :             :         {
      11                 :           0 :                 report("Memory management; Descriptor is NULL");
      12                 :           0 :                 status = FAILURE;
      13                 :             :         }
      14                 :             : 
      15         [ +  - ]:        8734 :         if(TRIUMPH & status)
      16                 :             :         {
      17                 :        8734 :                 const size_t previously_allocated = memory_structure->actually_allocated_bytes;
      18                 :        8734 :                 size_t previous_effective_bytes = 0;
      19                 :        8734 :                 size_t previous_alignment_overhead = 0;
      20                 :             : 
      21   [ +  -  -  + ]:        8734 :                 run(memory_guarded_size(memory_structure->element_size,
      22                 :             :                         memory_structure->length,
      23                 :             :                         &previous_effective_bytes));
      24                 :             : 
      25         [ +  + ]:        8734 :                 if(previously_allocated > previous_effective_bytes)
      26                 :             :                 {
      27                 :        3458 :                         previous_alignment_overhead = previously_allocated - previous_effective_bytes;
      28                 :             :                 }
      29                 :             : 
      30         [ +  + ]:        8734 :                 if(memory_structure->data != NULL)
      31                 :             :                 {
      32                 :        3574 :                         free(memory_structure->data);
      33                 :             : 
      34         [ +  - ]:        3574 :                         if(previously_allocated > 0)
      35                 :             :                         {
      36                 :        3574 :                                 telemetry_reduce(previously_allocated);
      37                 :        3574 :                                 telemetry_free_total_bytes(previously_allocated);
      38                 :             :                         }
      39                 :             : 
      40                 :        3574 :                         telemetry_free_counter();
      41                 :        3574 :                         telemetry_active_descriptor_release();
      42                 :             :                 }
      43                 :             : 
      44         [ +  + ]:        8734 :                 if(previous_effective_bytes > 0)
      45                 :             :                 {
      46                 :        3574 :                         telemetry_effective_reduce(previous_effective_bytes);
      47                 :             :                 }
      48                 :             : 
      49         [ +  + ]:        8734 :                 if(previous_alignment_overhead > 0)
      50                 :             :                 {
      51                 :        3458 :                         telemetry_alignment_overhead_reduce(previous_alignment_overhead);
      52                 :             :                 }
      53                 :             : 
      54                 :        8734 :                 memory_structure->data = NULL;
      55                 :        8734 :                 memory_structure->length = 0;
      56                 :        8734 :                 memory_structure->actually_allocated_bytes = 0;
      57                 :             :         }
      58                 :             : 
      59                 :        8734 :         provide(status);
      60                 :             : }
        

Generated by: LCOV version 2.0-1