Change-Id: I4bb5a73da0c9afc3fb6040e9063f5c1d92d87df2
#include "tbm_bufmgr_int.h"
#include "list.h"
#include "tbm_bufmgr_int.h"
#include "list.h"
+#define TBM_BO_MAGIC 0xBF011234
+
/* check condition */
#define TBM_BO_RETURN_IF_FAIL(cond) {\
if (!(cond)) {\
/* check condition */
#define TBM_BO_RETURN_IF_FAIL(cond) {\
if (!(cond)) {\
-_tbm_bo_is_valid(tbm_bo bo)
+_tbm_bo_magic_check(tbm_bo bo)
- tbm_bufmgr bufmgr = NULL;
- tbm_bo old_data = NULL;
-
- if (bo == NULL) {
- TBM_ERR("error: bo is NULL.\n");
+ if (bo->magic != TBM_BO_MAGIC)
- bufmgr = tbm_bufmgr_get();
- if (bufmgr == NULL) {
- TBM_ERR("error: bufmgr is NULL.\n");
- return 0;
- }
- if (LIST_IS_EMPTY(&bufmgr->bo_list)) {
- TBM_ERR("error: bo->bo->bufmgr->bo_list is EMPTY.\n");
+static int
+_tbm_bo_is_valid(tbm_bo bo)
+{
+ if (!bo) {
+ TBM_ERR("error: bo is NULL.\n");
- LIST_FOR_EACH_ENTRY(old_data, &bufmgr->bo_list, item_link) {
- if (old_data == bo)
- return 1;
+ if (!_tbm_bo_magic_check(bo)) {
+ TBM_ERR("error: No valid bo(%p).\n", bo);
+ return 0;
- TBM_ERR("error: No valid bo(%p).\n", bo);
-
- return 0;
+ bo->magic = TBM_BO_MAGIC;
bo->ref_cnt = 1;
bo->flags = flags;
bo->ref_cnt = 1;
bo->flags = flags;
+ bo->magic = TBM_BO_MAGIC;
bo->ref_cnt = 1;
if (bo->bufmgr->backend_module_data) {
bo->ref_cnt = 1;
if (bo->bufmgr->backend_module_data) {
+ bo->magic = TBM_BO_MAGIC;
bo->ref_cnt = 1;
if (bo->bufmgr->backend_module_data) {
bo->ref_cnt = 1;
if (bo->bufmgr->backend_module_data) {
bo->bufmgr->bo_cnt--;
LIST_DEL(&bo->item_link);
bo->bufmgr->bo_cnt--;
LIST_DEL(&bo->item_link);
* @brief tbm_bo : buffer object of Tizen Buffer Manager
*/
struct _tbm_bo {
* @brief tbm_bo : buffer object of Tizen Buffer Manager
*/
struct _tbm_bo {
+ unsigned int magic; /* tbm bo magic number */
tbm_bufmgr bufmgr; /* tbm buffer manager */
int ref_cnt; /* ref count of bo */
int flags; /* TBM_BO_FLAGS :bo memory type */
tbm_bufmgr bufmgr; /* tbm buffer manager */
int ref_cnt; /* ref count of bo */
int flags; /* TBM_BO_FLAGS :bo memory type */