LCOV - code coverage report
Current view: top level - lib - plugins.c (source / functions) Coverage Total Hit
Test: libblockdev Coverage Report Lines: 61.9 % 21 13
Test Date: 2026-01-23 09:12:16 Functions: 75.0 % 4 3
Legend: Lines: hit not hit

            Line data    Source code
       1              : #include <glib.h>
       2              : #include <glib-object.h>
       3              : #include "plugins.h"
       4              : 
       5              : /**
       6              :  * SECTION: plugins
       7              :  * @short_description: functions related to querying plugins
       8              :  * @title: Plugins
       9              :  * @include: blockdev.h
      10              :  */
      11              : 
      12              : /**
      13              :  * bd_plugin_spec_copy: (skip)
      14              :  * @spec: (nullable): %BDPluginSpec to copy
      15              :  *
      16              :  * Creates a new copy of @spec.
      17              :  */
      18            0 : BDPluginSpec* bd_plugin_spec_copy (BDPluginSpec *spec) {
      19            0 :     if (!spec)
      20            0 :         return NULL;
      21              : 
      22            0 :     BDPluginSpec *new_spec = g_new0 (BDPluginSpec, 1);
      23              : 
      24            0 :     new_spec->name = spec->name;
      25            0 :     new_spec->so_name = g_strdup (spec->so_name);
      26              : 
      27            0 :     return new_spec;
      28              : }
      29              : 
      30              : /**
      31              :  * bd_plugin_spec_free: (skip)
      32              :  * @spec: (nullable): %BDPluginSpec to free
      33              :  *
      34              :  * Frees @spec.
      35              :  */
      36           55 : void bd_plugin_spec_free (BDPluginSpec *spec) {
      37           55 :     if (!spec)
      38            0 :         return;
      39           55 :     g_free ((gchar *) spec->so_name);
      40           55 :     g_free (spec);
      41              : }
      42              : 
      43              : /**
      44              :  * bd_plugin_spec_new: (constructor)
      45              :  * @name: %BDPlugin name, e.g. %BD_PLUGIN_LVM
      46              :  * @so_name: (nullable): SO name of the plugin to load or %NULL for default
      47              :  *
      48              :  * Returns: (transfer full): a new plugin spec
      49              :  */
      50           68 : BDPluginSpec* bd_plugin_spec_new (BDPlugin name, const gchar *so_name) {
      51           68 :     BDPluginSpec* ret = g_new0 (BDPluginSpec, 1);
      52           68 :     ret->name = name;
      53              :     /* FIXME: this should be const, but we are already allocating a new string in _copy
      54              :     *         and freeing it in _free
      55              :     */
      56           93 :     ret->so_name = so_name ? g_strdup (so_name) : NULL;
      57              : 
      58           68 :     return ret;
      59              : }
      60              : 
      61            8 : GType bd_plugin_spec_get_type (void) {
      62              :     static GType type = 0;
      63              : 
      64            8 :     if (G_UNLIKELY(type == 0)) {
      65            1 :         type = g_boxed_type_register_static("BDPluginSpec",
      66              :                                             (GBoxedCopyFunc) bd_plugin_spec_copy,
      67              :                                             (GBoxedFreeFunc) bd_plugin_spec_free);
      68              :     }
      69              : 
      70            8 :     return type;
      71              : }
        

Generated by: LCOV version 2.0-1