root/lib/glibcompat.c

/* [previous][next][first][last][top][bottom][index][help]  */

DEFINITIONS

This source file includes following definitions.
  1. g_slist_free_full
  2. g_list_free_full
  3. g_queue_free_full
  4. g_queue_clear_full

   1 /*
   2    GLIB - Library of useful routines for C programming
   3 
   4    Copyright (C) 2009-2019
   5    Free Software Foundation, Inc.
   6 
   7    Written by:
   8    Slava Zanko <slavazanko@gmail.com>, 2009, 2013.
   9 
  10    This file is part of the Midnight Commander.
  11 
  12    The Midnight Commander is free software: you can redistribute it
  13    and/or modify it under the terms of the GNU General Public License as
  14    published by the Free Software Foundation, either version 3 of the License,
  15    or (at your option) any later version.
  16 
  17    The Midnight Commander is distributed in the hope that it will be useful,
  18    but WITHOUT ANY WARRANTY; without even the implied warranty of
  19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20    GNU General Public License for more details.
  21 
  22    You should have received a copy of the GNU General Public License
  23    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  24  */
  25 
  26 /** \file glibcompat.c
  27  *  \brief Source: compatibility with older versions of glib
  28  *
  29  *  Following code was copied from glib to GNU Midnight Commander to
  30  *  provide compatibility with older versions of glib.
  31  */
  32 
  33 #include <config.h>
  34 #include <string.h>
  35 
  36 #include "global.h"
  37 #include "glibcompat.h"
  38 
  39 /*** global variables ****************************************************************************/
  40 
  41 /*** file scope macro definitions ****************************************************************/
  42 
  43 /*** file scope type declarations ****************************************************************/
  44 
  45 /*** file scope variables ************************************************************************/
  46 
  47 /*** file scope functions ************************************************************************/
  48 
  49 /* --------------------------------------------------------------------------------------------- */
  50 /*** public functions ****************************************************************************/
  51 /* --------------------------------------------------------------------------------------------- */
  52 
  53 #if ! GLIB_CHECK_VERSION (2, 28, 0)
  54 /**
  55  * g_slist_free_full:
  56  * @list: a pointer to a #GSList
  57  * @free_func: the function to be called to free each element's data
  58  *
  59  * Convenience method, which frees all the memory used by a #GSList, and
  60  * calls the specified destroy function on every element's data.
  61  *
  62  * Since: 2.28
  63  **/
  64 void
  65 g_slist_free_full (GSList * list, GDestroyNotify free_func)
     /* [previous][next][first][last][top][bottom][index][help]  */
  66 {
  67     g_slist_foreach (list, (GFunc) free_func, NULL);
  68     g_slist_free (list);
  69 }
  70 
  71 /* --------------------------------------------------------------------------------------------- */
  72 
  73 /**
  74  * g_list_free_full:
  75  * @list: a pointer to a #GList
  76  * @free_func: the function to be called to free each element's data
  77  *
  78  * Convenience method, which frees all the memory used by a #GList, and
  79  * calls the specified destroy function on every element's data.
  80  *
  81  * Since: 2.28
  82  */
  83 void
  84 g_list_free_full (GList * list, GDestroyNotify free_func)
     /* [previous][next][first][last][top][bottom][index][help]  */
  85 {
  86     g_list_foreach (list, (GFunc) free_func, NULL);
  87     g_list_free (list);
  88 }
  89 
  90 /* --------------------------------------------------------------------------------------------- */
  91 
  92 #endif /* ! GLIB_CHECK_VERSION (2, 28, 0) */
  93 
  94 #if ! GLIB_CHECK_VERSION (2, 32, 0)
  95 /**
  96  * g_queue_free_full:
  97  * @queue: a pointer to a #GQueue
  98  * @free_func: the function to be called to free each element's data
  99  *
 100  * Convenience method, which frees all the memory used by a #GQueue,
 101  * and calls the specified destroy function on every element's data.
 102  *
 103  * Since: 2.32
 104  */
 105 void
 106 g_queue_free_full (GQueue * queue, GDestroyNotify free_func)
     /* [previous][next][first][last][top][bottom][index][help]  */
 107 {
 108     g_queue_foreach (queue, (GFunc) free_func, NULL);
 109     g_queue_free (queue);
 110 }
 111 #endif /* ! GLIB_CHECK_VERSION (2, 32, 0) */
 112 
 113 /* --------------------------------------------------------------------------------------------- */
 114 
 115 #if ! GLIB_CHECK_VERSION (2, 60, 0)
 116 /**
 117  * g_queue_clear_full:
 118  * @queue: a pointer to a #GQueue
 119  * @free_func: (nullable): the function to be called to free memory allocated
 120  *
 121  * Convenience method, which frees all the memory used by a #GQueue,
 122  * and calls the provided @free_func on each item in the #GQueue.
 123  *
 124  * Since: 2.60
 125  */
 126 void
 127 g_queue_clear_full (GQueue * queue, GDestroyNotify free_func)
     /* [previous][next][first][last][top][bottom][index][help]  */
 128 {
 129     g_return_if_fail (queue != NULL);
 130 
 131     if (free_func != NULL)
 132         g_queue_foreach (queue, (GFunc) free_func, NULL);
 133 
 134     g_queue_clear (queue);
 135 }
 136 #endif /* ! GLIB_CHECK_VERSION (2, 60, 0) */
 137 
 138 /* --------------------------------------------------------------------------------------------- */

/* [previous][next][first][last][top][bottom][index][help]  */