#include "tbm_bufmgr_int.h"
#include "list.h"
+#define TBM_BO_MAGIC 0xBF011234
+
/* check condition */
#define TBM_BO_RETURN_IF_FAIL(cond) {\
if (!(cond)) {\
}
static int
-_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)
return 0;
- }
- bufmgr = tbm_bufmgr_get();
- if (bufmgr == NULL) {
- TBM_ERR("error: bufmgr is NULL.\n");
- return 0;
- }
+ return 1;
+}
- 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");
return 0;
}
- 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;
+ return 1;
}
tbm_bo
}
bo->bufmgr->bo_cnt++;
+ bo->magic = TBM_BO_MAGIC;
bo->ref_cnt = 1;
bo->flags = flags;
}
bo->bufmgr->bo_cnt++;
+ bo->magic = TBM_BO_MAGIC;
bo->ref_cnt = 1;
if (bo->bufmgr->backend_module_data) {
}
bo->bufmgr->bo_cnt++;
+ bo->magic = TBM_BO_MAGIC;
bo->ref_cnt = 1;
if (bo->bufmgr->backend_module_data) {
bo->priv = NULL;
}
+ bo->magic = 0;
bo->bufmgr->bo_cnt--;
LIST_DEL(&bo->item_link);
* @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 */