LCOV - code coverage report
Current view: top level - src - system.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 14 14 100.0 %
Date: 2026-11-26 02:32:31 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 8 87.5 %

           Branch data     Line data    Source code
       1                 :            : // Copyright 2007-2025 David Robillard <d@drobilla.net>
       2                 :            : // SPDX-License-Identifier: ISC
       3                 :            : 
       4                 :            : #include "system.h"
       5                 :            : 
       6                 :            : #include "errno_status.h"
       7                 :            : 
       8                 :            : #include <zix/allocator.h>
       9                 :            : #include <zix/status.h>
      10                 :            : 
      11                 :            : #include <stddef.h>
      12                 :            : 
      13                 :            : ZixStatus
      14                 :         48 : zix_system_close_fds(const int fd1, const int fd2)
      15                 :            : {
      16                 :            :   // Careful: we need to always close both files, but catch errno at any point
      17                 :            : 
      18         [ +  + ]:         48 :   const int       r1  = fd1 >= 0 ? zix_system_close(fd1) : 0;
      19                 :         48 :   const ZixStatus st1 = zix_errno_status_if(r1);
      20         [ +  + ]:         48 :   const int       r2  = fd2 >= 0 ? zix_system_close(fd2) : 0;
      21                 :         48 :   const ZixStatus st2 = zix_errno_status_if(r2);
      22                 :            : 
      23         [ -  + ]:         48 :   return st1 ? st1 : st2;
      24                 :            : }
      25                 :            : 
      26                 :            : BlockBuffer
      27                 :         24 : zix_system_new_block(ZixAllocator* const allocator,
      28                 :            :                      const uint32_t      align,
      29                 :            :                      const uint32_t      size)
      30                 :            : {
      31                 :         24 :   BlockBuffer block = {size, NULL, {'\0'}};
      32                 :            : 
      33         [ +  + ]:         24 :   if (!(block.buffer = zix_aligned_alloc(allocator, align, size))) {
      34                 :          8 :     block.size = ZIX_STACK_BLOCK_SIZE;
      35                 :            :   }
      36                 :            : 
      37                 :         24 :   return block;
      38                 :            : }
      39                 :            : 
      40                 :            : void
      41                 :         24 : zix_system_free_block(ZixAllocator* const allocator, const BlockBuffer block)
      42                 :            : {
      43                 :         24 :   zix_aligned_free(allocator, block.buffer);
      44                 :         24 : }

Generated by: LCOV version 1.16