LCOV - code coverage report
Current view: top level - lib - memcat_p.c (source / functions) Hit Total Coverage
Test: combined.info Lines: 0 12 0.0 %
Date: 2022-03-28 15:32:58 Functions: 0 1 0.0 %
Branches: 0 10 0.0 %

           Branch data     Line data    Source code
       1                 :            : // SPDX-License-Identifier: GPL-2.0
       2                 :            : 
       3                 :            : #include <linux/slab.h>
       4                 :            : 
       5                 :            : /*
       6                 :            :  * Merge two NULL-terminated pointer arrays into a newly allocated
       7                 :            :  * array, which is also NULL-terminated. Nomenclature is inspired by
       8                 :            :  * memset_p() and memcat() found elsewhere in the kernel source tree.
       9                 :            :  */
      10                 :          0 : void **__memcat_p(void **a, void **b)
      11                 :            : {
      12                 :          0 :         void **p = a, **new;
      13                 :          0 :         int nr;
      14                 :            : 
      15                 :            :         /* count the elements in both arrays */
      16         [ #  # ]:          0 :         for (nr = 0, p = a; *p; nr++, p++)
      17                 :          0 :                 ;
      18         [ #  # ]:          0 :         for (p = b; *p; nr++, p++)
      19                 :          0 :                 ;
      20                 :            :         /* one for the NULL-terminator */
      21                 :          0 :         nr++;
      22                 :            : 
      23                 :          0 :         new = kmalloc_array(nr, sizeof(void *), GFP_KERNEL);
      24         [ #  # ]:          0 :         if (!new)
      25                 :            :                 return NULL;
      26                 :            : 
      27                 :            :         /* nr -> last index; p points to NULL in b[] */
      28         [ #  # ]:          0 :         for (nr--; nr >= 0; nr--, p = p == b ? &a[nr] : p - 1)
      29         [ #  # ]:          0 :                 new[nr] = *p;
      30                 :            : 
      31                 :            :         return new;
      32                 :            : }
      33                 :            : EXPORT_SYMBOL_GPL(__memcat_p);
      34                 :            : 

Generated by: LCOV version 1.14