gmyth/src/libgmyth/gmyth_common.c
author leo_sobral
Wed Sep 20 23:45:35 2006 +0100 (2006-09-20)
branchtrunk
changeset 1 ffdf467315ec
permissions -rw-r--r--
[svn r2] imported to sf repository
leo_sobral@1
     1
/**
leo_sobral@1
     2
 * GMyth Library
leo_sobral@1
     3
 *
leo_sobral@1
     4
 * @file gmyth/gmyth_common.c
leo_sobral@1
     5
 * 
leo_sobral@1
     6
 * @brief <p> This file contains basic common functions for the gmyth library.
leo_sobral@1
     7
 *
leo_sobral@1
     8
 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
leo_sobral@1
     9
 * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
leo_sobral@1
    10
 *
leo_sobral@1
    11
 *//*
leo_sobral@1
    12
 * 
leo_sobral@1
    13
 * This program is free software; you can redistribute it and/or modify
leo_sobral@1
    14
 * it under the terms of the GNU Lesser General Public License as published by
leo_sobral@1
    15
 * the Free Software Foundation; either version 2 of the License, or
leo_sobral@1
    16
 * (at your option) any later version.
leo_sobral@1
    17
 *
leo_sobral@1
    18
 * This program is distributed in the hope that it will be useful,
leo_sobral@1
    19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
leo_sobral@1
    20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
leo_sobral@1
    21
 * GNU General Public License for more details.
leo_sobral@1
    22
 *
leo_sobral@1
    23
 * You should have received a copy of the GNU Lesser General Public License
leo_sobral@1
    24
 * along with this program; if not, write to the Free Software
leo_sobral@1
    25
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
leo_sobral@1
    26
 */
leo_sobral@1
    27
leo_sobral@1
    28
#include "gmyth_common.h"
leo_sobral@1
    29
leo_sobral@1
    30
static void free_channel_data(gpointer data, gpointer user_data);
leo_sobral@1
    31
static void free_program_data(gpointer data, gpointer user_data);
leo_sobral@1
    32
leo_sobral@1
    33
/** Frees the memory allocated to the GMythChannelInfo objects inside list.
leo_sobral@1
    34
 * The list memory is also released by g_list_free(). If LIST is NULL it
leo_sobral@1
    35
 * simply returns.
leo_sobral@1
    36
 * 
leo_sobral@1
    37
 * @param list the GList containing a list of GMythChannelInfo to free.
leo_sobral@1
    38
 */
leo_sobral@1
    39
void 
leo_sobral@1
    40
gmyth_free_channel_list(GList *list) 
leo_sobral@1
    41
{
leo_sobral@1
    42
	if (list == NULL) {
leo_sobral@1
    43
		g_warning ("%s received null GList as parameter", __FUNCTION__);
leo_sobral@1
    44
		return;
leo_sobral@1
    45
	}
leo_sobral@1
    46
	
leo_sobral@1
    47
	g_list_foreach (list, free_channel_data, NULL);
leo_sobral@1
    48
	
leo_sobral@1
    49
	g_list_free (list);
leo_sobral@1
    50
}
leo_sobral@1
    51
leo_sobral@1
    52
/** Frees the memory allocated to the GMythProgramInfo objects inside list.
leo_sobral@1
    53
 * The list memory is also released by g_list_free(). If list is NULL it
leo_sobral@1
    54
 * simply returns.
leo_sobral@1
    55
 * 
leo_sobral@1
    56
 * @param list the GList containing a list of GMythProgramInfo to free.
leo_sobral@1
    57
 */
leo_sobral@1
    58
void
leo_sobral@1
    59
gmyth_free_program_list(GList *list)
leo_sobral@1
    60
{
leo_sobral@1
    61
	if (list == NULL) {
leo_sobral@1
    62
		g_warning ("%s received null GList as parameter", __FUNCTION__);
leo_sobral@1
    63
		return;
leo_sobral@1
    64
	}
leo_sobral@1
    65
	
leo_sobral@1
    66
	g_list_foreach (list, free_program_data, NULL);
leo_sobral@1
    67
	
leo_sobral@1
    68
	g_list_free (list);
leo_sobral@1
    69
}
leo_sobral@1
    70
leo_sobral@1
    71
leo_sobral@1
    72
static void 
leo_sobral@1
    73
free_channel_data(gpointer data, gpointer user_data)
leo_sobral@1
    74
{
leo_sobral@1
    75
    if(data)
leo_sobral@1
    76
        g_free((GMythChannelInfo*) data);
leo_sobral@1
    77
}
leo_sobral@1
    78
leo_sobral@1
    79
static void
leo_sobral@1
    80
free_program_data(gpointer data, gpointer user_data)
leo_sobral@1
    81
{
leo_sobral@1
    82
    if(data)
leo_sobral@1
    83
        g_free((GMythProgramInfo*) data);
leo_sobral@1
    84
}
leo_sobral@1
    85