Commit 7f132123 authored by Jean-Paul Saman's avatar Jean-Paul Saman

src/tables/pat.*: Make dvbpsi_NewPat() and dvbpsi_DeletePAT() functions.

parent 3b681a1b
......@@ -109,12 +109,28 @@ void dvbpsi_DetachPAT(dvbpsi_t *p_dvbpsi)
void dvbpsi_InitPAT(dvbpsi_pat_t* p_pat, uint16_t i_ts_id, uint8_t i_version,
bool b_current_next)
{
assert(p_pat);
p_pat->i_ts_id = i_ts_id;
p_pat->i_version = i_version;
p_pat->b_current_next = b_current_next;
p_pat->p_first_program = NULL;
}
/*****************************************************************************
* dvbpsi_NewPAT
*****************************************************************************
* Allocate and Initialize a newly allocated dvbpsi_pat_t structure.
*****************************************************************************/
dvbpsi_pat_t *dvbpsi_NewPAT(uint16_t i_ts_id, uint8_t i_version,
bool b_current_next)
{
dvbpsi_pat_t *p_pat = (dvbpsi_pat_t*)malloc(sizeof(dvbpsi_pat_t));
if (p_pat)
dvbpsi_InitPAT(p_pat, i_ts_id, i_version, b_current_next);
return p_pat;
}
/*****************************************************************************
* dvbpsi_EmptyPAT
*****************************************************************************
......@@ -133,6 +149,18 @@ void dvbpsi_EmptyPAT(dvbpsi_pat_t* p_pat)
p_pat->p_first_program = NULL;
}
/*****************************************************************************
* dvbpsi_DeletePAT
*****************************************************************************
* Clean and Delete dvbpsi_pat_t structure.
*****************************************************************************/
void dvbpsi_DeletePAT(dvbpsi_pat_t *p_pat)
{
if (p_pat)
dvbpsi_EmptyPAT(p_pat);
free(p_pat);
}
/*****************************************************************************
* dvbpsi_PATAddProgram
*****************************************************************************
......
......@@ -142,20 +142,15 @@ void dvbpsi_InitPAT(dvbpsi_pat_t* p_pat, uint16_t i_ts_id, uint8_t i_version,
bool b_current_next);
/*!
* \def dvbpsi_NewPAT(p_pat, i_ts_id, i_version, b_current_next)
* \def dvbpsi_pat_t *dvbpsi_NewPAT(uint16_t i_ts_id, uint8_t i_version,
* bool b_current_next);
* \brief Allocate and initialize a new dvbpsi_pat_t structure.
* \param p_pat pointer to the PAT structure
* \param i_ts_id transport stream ID
* \param i_version PAT version
* \param b_current_next current next indicator
* \return nothing.
* \return p_pat pointer to the PAT structure
*/
#define dvbpsi_NewPAT(p_pat, i_ts_id, i_version, b_current_next) \
do { \
p_pat = (dvbpsi_pat_t*)malloc(sizeof(dvbpsi_pat_t)); \
if(p_pat != NULL) \
dvbpsi_InitPAT(p_pat, i_ts_id, i_version, b_current_next); \
} while(0);
dvbpsi_pat_t *dvbpsi_NewPAT(uint16_t i_ts_id, uint8_t i_version, bool b_current_next);
/*****************************************************************************
* dvbpsi_EmptyPAT/dvbpsi_DeletePAT
......@@ -169,16 +164,12 @@ do { \
void dvbpsi_EmptyPAT(dvbpsi_pat_t* p_pat);
/*!
* \def dvbpsi_DeletePAT(p_pat)
* \def void dvbpsi_DeletePAT(dvbpsi_pat_t (*_pat)
* \brief Clean and free a dvbpsi_pat_t structure.
* \param p_pat pointer to the PAT structure
* \return nothing.
*/
#define dvbpsi_DeletePAT(p_pat) \
do { \
dvbpsi_EmptyPAT(p_pat); \
free(p_pat); \
} while(0);
void dvbpsi_DeletePAT(dvbpsi_pat_t *p_pat);
/*****************************************************************************
* dvbpsi_PATAddProgram
......
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