Change-Id: If6c987d276c97d2a21ba38c76d0a01e66cbdcfe5
*
*/
struct _tbm_surface {
*
*/
struct _tbm_surface {
+ unsigned int magic; /* tbm surface magic number */
+
tbm_bufmgr bufmgr; /* tbm buffer manager */
tbm_surface_info_s info; /* tbm surface information */
tbm_bufmgr bufmgr; /* tbm buffer manager */
tbm_surface_info_s info; /* tbm surface information */
#include <png.h>
#include <pixman.h>
#include <png.h>
#include <pixman.h>
+#define TBM_SURFACE_MAGIC 0xBF021234
+
static tbm_bufmgr g_surface_bufmgr;
static pthread_mutex_t tbm_surface_lock = PTHREAD_MUTEX_INITIALIZER;
void _tbm_surface_mutex_unlock(void);
static tbm_bufmgr g_surface_bufmgr;
static pthread_mutex_t tbm_surface_lock = PTHREAD_MUTEX_INITIALIZER;
void _tbm_surface_mutex_unlock(void);
/* LCOV_EXCL_STOP */
static int
/* LCOV_EXCL_STOP */
static int
-_tbm_surface_internal_is_valid(tbm_surface_h surface)
+_tbm_surface_internal_magic_check(tbm_surface_h surface)
- tbm_surface_h old_data = NULL;
+ if (surface->magic != TBM_SURFACE_MAGIC)
+ return 0;
- TBM_RETURN_VAL_IF_FAIL(g_surface_bufmgr, 0);
- TBM_RETURN_VAL_IF_FAIL(surface, 0);
- if (!LIST_IS_EMPTY(&g_surface_bufmgr->surf_list)) {
- LIST_FOR_EACH_ENTRY(old_data, &g_surface_bufmgr->surf_list, item_link) {
- if (old_data == surface)
- return 1;
- }
+static int
+_tbm_surface_internal_is_valid(tbm_surface_h surface)
+{
+ if (!surface) {
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
+ TBM_ERR("error: No valid tbm_surface is NULL\n");
+ return 0;
- _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
-
- TBM_ERR("error: No valid tbm_surface(%p)\n", surface);
+ if (!_tbm_surface_internal_magic_check(surface)) {
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
+ TBM_ERR("error: No valid tbm_surface(%p)\n", surface);
+ return 0;
+ }
}
LIST_DEL(&surface->item_link);
}
LIST_DEL(&surface->item_link);
free(surface);
surface = NULL;
free(surface);
surface = NULL;
+ surf->magic = TBM_SURFACE_MAGIC;
surf->bufmgr = bufmgr;
surf->info.width = width;
surf->info.height = height;
surf->bufmgr = bufmgr;
surf->info.width = width;
surf->info.height = height;
+ surf->magic = TBM_SURFACE_MAGIC;
surf->bufmgr = bufmgr;
surf->info.width = info->width;
surf->info.height = info->height;
surf->bufmgr = bufmgr;
surf->info.width = info->width;
surf->info.height = info->height;