[osal]: add clear operation to mpp_free

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@210 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenHengming
2008-01-29 23:29:40 +00:00
parent b56729adb9
commit 70090757a3
9 changed files with 17 additions and 25 deletions

View File

@@ -93,8 +93,7 @@ MPP_RET mpp_buf_slot_deinit(MppBufSlots slots)
MppBufSlotsImpl *impl = (MppBufSlotsImpl *)slots; MppBufSlotsImpl *impl = (MppBufSlotsImpl *)slots;
delete impl->lock; delete impl->lock;
if (impl->slots) mpp_free(impl->slots);
mpp_free(impl->slots);
mpp_free(slots); mpp_free(slots);
return MPP_OK; return MPP_OK;
} }

View File

@@ -252,7 +252,7 @@ MPP_RET mpp_dec_init(MppDec **dec, MppCodingType coding)
// then init hal with task count from parser // then init hal with task count from parser
MppHalCfg hal_cfg = { MppHalCfg hal_cfg = {
MPP_CTX_DEC, MPP_CTX_DEC,
MPP_VIDEO_CodingAVC, coding,
NULL, NULL,
parser_cfg.task_count, parser_cfg.task_count,
}; };
@@ -279,8 +279,7 @@ MPP_RET mpp_dec_deinit(MppDec *dec)
return MPP_ERR_NULL_PTR; return MPP_ERR_NULL_PTR;
} }
if (dec->parser_ctx) mpp_free(dec->parser_ctx);
mpp_free(dec->parser_ctx);
if (dec->hal_ctx) if (dec->hal_ctx)
mpp_hal_deinit(dec->hal_ctx); mpp_hal_deinit(dec->hal_ctx);

View File

@@ -83,8 +83,7 @@ MPP_RET mpp_hal_init(MppHal *ctx, MppHalCfg *cfg)
} }
mpp_err_f("could not found coding type %d\n", cfg->coding); mpp_err_f("could not found coding type %d\n", cfg->coding);
if (p->ctx) mpp_free(p->ctx);
mpp_free(p->ctx);
mpp_free(p); mpp_free(p);
return MPP_NOK; return MPP_NOK;
@@ -98,8 +97,7 @@ MPP_RET mpp_hal_deinit(MppHal ctx)
} }
MppHalImpl *p = (MppHalImpl*)ctx; MppHalImpl *p = (MppHalImpl*)ctx;
if (p->ctx) mpp_free(p->ctx);
mpp_free(p->ctx);
if (p->tasks) if (p->tasks)
hal_task_group_deinit(p->tasks); hal_task_group_deinit(p->tasks);
mpp_free(p); mpp_free(p);

View File

@@ -224,14 +224,8 @@ RK_S32 vpu_close_context(VpuCodecContext **ctx)
delete api; delete api;
s->vpuApiObj = NULL; s->vpuApiObj = NULL;
} }
if (s->extradata) { mpp_free(s->extradata);
mpp_free(s->extradata); mpp_free(s->private_data);
s->extradata = NULL;
}
if (s->private_data) {
mpp_free(s->private_data);
s->private_data = NULL;
}
mpp_free(s); mpp_free(s);
*ctx = s = NULL; *ctx = s = NULL;

View File

@@ -224,8 +224,7 @@ MPP_RET mpp_deinit(MppCtx ctx)
if (p->ctx) if (p->ctx)
delete p->ctx; delete p->ctx;
if (p) mpp_free(p);
mpp_free(p);
MPI_FUNCTION_LEAVE(); MPI_FUNCTION_LEAVE();
return MPP_OK; return MPP_OK;

View File

@@ -154,8 +154,7 @@ void Mpp::clear()
mpp_buffer_group_put(mFrameGroup); mpp_buffer_group_put(mFrameGroup);
mFrameGroup = NULL; mFrameGroup = NULL;
} }
if (mTask) mpp_free(mTask);
mpp_free(mTask);
} }
MPP_RET Mpp::put_packet(MppPacket packet) MPP_RET Mpp::put_packet(MppPacket packet)

View File

@@ -58,7 +58,6 @@ MPP_RET mpp_packet_deinit(MppPacket *packet)
} }
mpp_free(*packet); mpp_free(*packet);
*packet = NULL;
return MPP_OK; return MPP_OK;
} }

View File

@@ -36,7 +36,13 @@
#define mpp_realloc(ptr, type, count) \ #define mpp_realloc(ptr, type, count) \
(type*)mpp_osal_realloc(MODULE_TAG, ptr, sizeof(type) * (count)) (type*)mpp_osal_realloc(MODULE_TAG, ptr, sizeof(type) * (count))
#define mpp_free(ptr) mpp_osal_free(ptr) #define mpp_free(ptr) \
do { \
if (ptr) { \
mpp_osal_free(ptr); \
ptr = NULL; \
} \
} while (0)
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@@ -121,8 +121,7 @@ MPP_RET mpp_alloctor_put(MppAllocator *allocator)
if (p->os_api.close) if (p->os_api.close)
p->os_api.close(p->ctx); p->os_api.close(p->ctx);
pthread_mutex_destroy(&p->lock); pthread_mutex_destroy(&p->lock);
if (p) mpp_free(p);
mpp_free(p);
return MPP_OK; return MPP_OK;
} }