Commit 1ac4cd61 authored by Jean-Paul Saman's avatar Jean-Paul Saman

src/tables/nit.*: Make dvbpsi_NewNIT() and dvbpsi_DeleteNIT() functions.

parent a2893188
...@@ -151,7 +151,7 @@ void dvbpsi_DetachNIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, ...@@ -151,7 +151,7 @@ void dvbpsi_DetachNIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id,
p_subdec = NULL; p_subdec = NULL;
} }
/***************************************************************************** /****************************************************************************
* dvbpsi_InitNIT * dvbpsi_InitNIT
***************************************************************************** *****************************************************************************
* Initialize a pre-allocated dvbpsi_nit_t structure. * Initialize a pre-allocated dvbpsi_nit_t structure.
...@@ -166,6 +166,20 @@ void dvbpsi_InitNIT(dvbpsi_nit_t* p_nit, uint16_t i_network_id, ...@@ -166,6 +166,20 @@ void dvbpsi_InitNIT(dvbpsi_nit_t* p_nit, uint16_t i_network_id,
p_nit->p_first_ts = NULL; p_nit->p_first_ts = NULL;
} }
/****************************************************************************
* dvbpsi_NewNIT
*****************************************************************************
* Allocate and initialize a dvbpsi_nit_t structure.
*****************************************************************************/
dvbpsi_nit_t *dvbpsi_NewNIT(uint16_t i_network_id, uint8_t i_version,
bool b_current_next)
{
dvbpsi_nit_t*p_nit = (dvbpsi_nit_t*)malloc(sizeof(dvbpsi_nit_t));
if (p_nit != NULL)
dvbpsi_InitNIT(p_nit, i_network_id, i_version, b_current_next);
return p_nit;
}
/***************************************************************************** /*****************************************************************************
* dvbpsi_EmptyNIT * dvbpsi_EmptyNIT
***************************************************************************** *****************************************************************************
...@@ -189,6 +203,18 @@ void dvbpsi_EmptyNIT(dvbpsi_nit_t* p_nit) ...@@ -189,6 +203,18 @@ void dvbpsi_EmptyNIT(dvbpsi_nit_t* p_nit)
p_nit->p_first_ts = NULL; p_nit->p_first_ts = NULL;
} }
/****************************************************************************
* dvbpsi_DeleteNIT
*****************************************************************************
* Clean and delete a dvbpsi_nit_t structure.
*****************************************************************************/
void dvbpsi_DeleteNIT(dvbpsi_nit_t *p_nit)
{
if (p_nit)
dvbpsi_EmptyNIT(p_nit);
free(p_nit);
}
/***************************************************************************** /*****************************************************************************
* dvbpsi_NITAddDescriptor * dvbpsi_NITAddDescriptor
***************************************************************************** *****************************************************************************
......
...@@ -153,22 +153,16 @@ void dvbpsi_InitNIT(dvbpsi_nit_t* p_nit, uint16_t i_network_id, ...@@ -153,22 +153,16 @@ void dvbpsi_InitNIT(dvbpsi_nit_t* p_nit, uint16_t i_network_id,
uint8_t i_version, bool b_current_next); uint8_t i_version, bool b_current_next);
/*! /*!
* \def dvbpsi_NewNIT(p_nit, i_network_id, * \fn dvbpsi_nit_t *dvbpsi_NewNIT(uint16_t i_ts_id, uint8_t i_version,
i_version, b_current_next) * bool b_current_next);
* \brief Allocate and initialize a new dvbpsi_nit_t structure. * \brief Allocate and initialize a new dvbpsi_nit_t structure.
* \param p_nit pointer to the NIT structure
* \param i_network_id network id * \param i_network_id network id
* \param i_version NIT version * \param i_version NIT version
* \param b_current_next current next indicator * \param b_current_next current next indicator
* \return nothing. * \return p_nit pointer to the NIT structure
*/ */
#define dvbpsi_NewNIT(p_nit, i_network_id, \ dvbpsi_nit_t *dvbpsi_NewNIT(uint16_t i_network_id, uint8_t i_version,
i_version, b_current_next) \ bool b_current_next);
do { \
p_nit = (dvbpsi_nit_t*)malloc(sizeof(dvbpsi_nit_t)); \
if(p_nit != NULL) \
dvbpsi_InitNIT(p_nit, i_network_id, i_version, b_current_next); \
} while(0);
/***************************************************************************** /*****************************************************************************
* dvbpsi_EmptyNIT/dvbpsi_DeleteNIT * dvbpsi_EmptyNIT/dvbpsi_DeleteNIT
...@@ -182,16 +176,12 @@ do { \ ...@@ -182,16 +176,12 @@ do { \
void dvbpsi_EmptyNIT(dvbpsi_nit_t* p_nit); void dvbpsi_EmptyNIT(dvbpsi_nit_t* p_nit);
/*! /*!
* \def dvbpsi_DeleteNIT(p_nit) * \fn dvbpsi_DeleteNIT(dvbpsi_nit_t *p_nit)
* \brief Clean and free a dvbpsi_nit_t structure. * \brief Clean and free a dvbpsi_nit_t structure.
* \param p_nit pointer to the NIT structure * \param p_nit pointer to the NIT structure
* \return nothing. * \return nothing.
*/ */
#define dvbpsi_DeleteNIT(p_nit) \ void dvbpsi_DeleteNIT(dvbpsi_nit_t *p_nit);
do { \
dvbpsi_EmptyNIT(p_nit); \
free(p_nit); \
} while(0);
/***************************************************************************** /*****************************************************************************
* dvbpsi_NITAddDescriptor * dvbpsi_NITAddDescriptor
......
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