Commit ef8352ef authored by Jean-Paul Saman's avatar Jean-Paul Saman

src/tables/cat.*: Make dvbpsi_NewCAT() and dvbpsi_DeleteCAT() functions.

parent dd248c84
...@@ -115,6 +115,19 @@ void dvbpsi_InitCAT(dvbpsi_cat_t* p_cat, uint8_t i_version, bool b_current_next) ...@@ -115,6 +115,19 @@ void dvbpsi_InitCAT(dvbpsi_cat_t* p_cat, uint8_t i_version, bool b_current_next)
p_cat->p_first_descriptor = NULL; p_cat->p_first_descriptor = NULL;
} }
/*****************************************************************************
* dvbpsi_NewCAT
*****************************************************************************
* Allocate and Initialize a dvbpsi_cat_t structure.
*****************************************************************************/
dvbpsi_cat_t *dvbpsi_NewCAT(uint8_t i_version, bool b_current_next)
{
dvbpsi_cat_t *p_cat = (dvbpsi_cat_t*)malloc(sizeof(dvbpsi_cat_t));
if (p_cat != NULL)
dvbpsi_InitCAT(p_cat, i_version, b_current_next);
return p_cat;
}
/***************************************************************************** /*****************************************************************************
* dvbpsi_EmptyCAT * dvbpsi_EmptyCAT
***************************************************************************** *****************************************************************************
...@@ -126,6 +139,18 @@ void dvbpsi_EmptyCAT(dvbpsi_cat_t* p_cat) ...@@ -126,6 +139,18 @@ void dvbpsi_EmptyCAT(dvbpsi_cat_t* p_cat)
p_cat->p_first_descriptor = NULL; p_cat->p_first_descriptor = NULL;
} }
/*****************************************************************************
* dvbpsi_DeleteCAT
*****************************************************************************
* Clean a dvbpsi_cat_t structure.
*****************************************************************************/
void dvbpsi_DeleteCAT(dvbpsi_cat_t *p_cat)
{
if (p_cat)
dvbpsi_EmptyCAT(p_cat);
free(p_cat);
}
/***************************************************************************** /*****************************************************************************
* dvbpsi_CATAddDescriptor * dvbpsi_CATAddDescriptor
***************************************************************************** *****************************************************************************
......
/***************************************************************************** /*****************************************************************************
* cat.h * cat.h
* Copyright (C) 2001-2010 VideoLAN * Copyright (C) 2001-2011 VideoLAN
* $Id$ * $Id$
* *
* Authors: Johann Hanne * Authors: Johann Hanne
...@@ -118,21 +118,14 @@ void dvbpsi_InitCAT(dvbpsi_cat_t* p_cat, ...@@ -118,21 +118,14 @@ void dvbpsi_InitCAT(dvbpsi_cat_t* p_cat,
uint8_t i_version, bool b_current_next); uint8_t i_version, bool b_current_next);
/*! /*!
* \def dvbpsi_NewCAT(p_cat, * \fn dvbpsi_cat_t *dvbpsi_NewCAT(uint8_t i_version,
i_version, b_current_next) * bool b_current_next)
* \brief Allocate and initialize a new dvbpsi_cat_t structure. * \brief Allocate and initialize a new dvbpsi_cat_t structure.
* \param p_cat pointer to the CAT structure
* \param i_version CAT version * \param i_version CAT version
* \param b_current_next current next indicator * \param b_current_next current next indicator
* \return nothing. * \return p_cat pointer to the CAT structure
*/ */
#define dvbpsi_NewCAT(p_cat, \ dvbpsi_cat_t *dvbpsi_NewCAT(uint8_t i_version, bool b_current_next);
i_version, b_current_next) \
do { \
p_cat = (dvbpsi_cat_t*)malloc(sizeof(dvbpsi_cat_t)); \
if(p_cat != NULL) \
dvbpsi_InitCAT(p_cat, i_version, b_current_next); \
} while(0);
/***************************************************************************** /*****************************************************************************
* dvbpsi_EmptyCAT/dvbpsi_DeleteCAT * dvbpsi_EmptyCAT/dvbpsi_DeleteCAT
...@@ -146,16 +139,12 @@ do { \ ...@@ -146,16 +139,12 @@ do { \
void dvbpsi_EmptyCAT(dvbpsi_cat_t* p_cat); void dvbpsi_EmptyCAT(dvbpsi_cat_t* p_cat);
/*! /*!
* \def dvbpsi_DeleteCAT(p_cat) * \fn void dvbpsi_DeleteCAT(dvbpsi_cat_t *p_cat)
* \brief Clean and free a dvbpsi_cat_t structure. * \brief Clean and free a dvbpsi_cat_t structure.
* \param p_cat pointer to the CAT structure * \param p_cat pointer to the CAT structure
* \return nothing. * \return nothing.
*/ */
#define dvbpsi_DeleteCAT(p_cat) \ void dvbpsi_DeleteCAT(dvbpsi_cat_t *p_cat);
do { \
dvbpsi_EmptyCAT(p_cat); \
free(p_cat); \
} while(0);
/***************************************************************************** /*****************************************************************************
* dvbpsi_CATAddDescriptor * dvbpsi_CATAddDescriptor
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment