Commit 65c6adaa authored by hpi1's avatar hpi1

indx_free(), mobj_free(), hdmv_vm_free(): changed argument to **. Set original pointer to NULL.

parent 83d4597c
......@@ -119,7 +119,7 @@ int main(int argc, const char *argv[])
if (index) {
_indx_print(index);
indx_free(index);
indx_free(&index);
}
return 0;
......
......@@ -76,7 +76,7 @@ int main(int argc, const char *argv[])
if (mobj) {
_mobj_print(mobj, disasm);
mobj_free(mobj);
mobj_free(&mobj);
}
return 0;
......
......@@ -188,10 +188,10 @@ INDX_ROOT *indx_parse(const char *file_name)
return NULL;
}
void indx_free(INDX_ROOT *index)
void indx_free(INDX_ROOT **p)
{
if (index) {
X_FREE(index->titles);
X_FREE(index);
if (p && *p) {
X_FREE((*p)->titles);
X_FREE(*p);
}
}
......@@ -107,7 +107,7 @@ typedef struct indx_root_s {
BD_PRIVATE INDX_ROOT* indx_parse(const char *path); /* parse index.bdmv */
BD_PRIVATE void indx_free(INDX_ROOT *index);
BD_PRIVATE void indx_free(INDX_ROOT **index);
#endif // _INDX_PARSE_H_
......@@ -519,10 +519,9 @@ void bd_close(BLURAY *bd)
nav_title_close(bd->title);
}
if (bd->hdmv_vm)
hdmv_vm_free(bd->hdmv_vm);
hdmv_vm_free(&bd->hdmv_vm);
indx_free(bd->index);
indx_free(&bd->index);
bd_registers_free(bd->regs);
X_FREE(bd->event_queue);
......@@ -1361,8 +1360,7 @@ int bd_play(BLURAY *bd)
bd->title_type = title_undef;
if (bd->hdmv_vm) {
hdmv_vm_free(bd->hdmv_vm);
bd->hdmv_vm = NULL;
hdmv_vm_free(&bd->hdmv_vm);
bd->hdmv_suspended = 1;
}
......
......@@ -246,16 +246,19 @@ HDMV_VM *hdmv_vm_init(const char *disc_root, BD_REGISTERS *regs)
return p;
}
void hdmv_vm_free(HDMV_VM *p)
void hdmv_vm_free(HDMV_VM **p)
{
mobj_free(p->movie_objects);
if (p && *p) {
if (p->ig_object) {
X_FREE(p->ig_object->cmds);
X_FREE(p->ig_object);
}
mobj_free(&(*p)->movie_objects);
X_FREE(p);
if ((*p)->ig_object) {
X_FREE((*p)->ig_object->cmds);
X_FREE((*p)->ig_object);
}
X_FREE(*p);
}
}
/*
......
......@@ -65,7 +65,7 @@ struct bd_registers_s;
typedef struct hdmv_vm_s HDMV_VM;
BD_PRIVATE HDMV_VM *hdmv_vm_init(const char *disc_root, struct bd_registers_s *regs);
BD_PRIVATE void hdmv_vm_free(HDMV_VM *p);
BD_PRIVATE void hdmv_vm_free(HDMV_VM **p);
BD_PRIVATE int hdmv_vm_select_object(HDMV_VM *p, int object);
BD_PRIVATE int hdmv_vm_set_object(HDMV_VM *p, int num_nav_cmds, void *nav_cmds);
......
......@@ -96,16 +96,16 @@ static int _mobj_parse_object(BITSTREAM *bs, MOBJ_OBJECT *obj)
return 1;
}
void mobj_free(MOBJ_OBJECTS *objects)
void mobj_free(MOBJ_OBJECTS **p)
{
if (objects) {
if (p && *p) {
int i;
for (i = 0 ; i < objects->num_objects; i++) {
X_FREE(objects->objects[i].cmds);
for (i = 0 ; i < (*p)->num_objects; i++) {
X_FREE((*p)->objects[i].cmds);
}
X_FREE(objects);
X_FREE(*p);
}
}
......@@ -152,7 +152,7 @@ MOBJ_OBJECTS *mobj_parse(const char *file_name)
return objects;
error:
mobj_free(objects);
mobj_free(&objects);
file_close(fp);
return NULL;
}
......@@ -64,7 +64,7 @@ typedef struct {
BD_PRIVATE MOBJ_OBJECTS* mobj_parse(const char *path) BD_ATTR_MALLOC; /* parse MovieObject.bdmv */
BD_PRIVATE void mobj_parse_cmd(uint8_t *buf, MOBJ_CMD *cmd);
BD_PRIVATE void mobj_free(MOBJ_OBJECTS *index);
BD_PRIVATE void mobj_free(MOBJ_OBJECTS **index);
BD_PRIVATE int mobj_sprint_cmd(char *buf, MOBJ_CMD *cmd); /* print MOBJ_CMD to string. buf is expected to be 256 bytes. */
......
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