tbm_surface_queue: clean up tbm_surface_queue_init / destroy 99/96299/1
authorYoungJun Cho <yj44.cho@samsung.com>
Tue, 8 Nov 2016 10:47:39 +0000 (19:47 +0900)
committerYoungJun Cho <yj44.cho@samsung.com>
Tue, 8 Nov 2016 10:47:39 +0000 (19:47 +0900)
This patch cleans up tbm_surface_queue_init / destroy.
- The surface_queue is created by calloc, so memset() is not required
  in tbm_surface_queue_init().
- There are missed _notify_remove_all() calls for dequeue_noti and acquirable_noti
  in tbm_surface_queue_destroy().
- Reorders notifications list as structure defined order.

Change-Id: I2ab5312a4dd686cb55beca5c7601a849fd00412a
Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
src/tbm_surface_queue.c

index 90fc623906bf0379c91aaaac8d6ad132a31a10a8..1298cfdbf93f797366ab6e2764c4f83abfa4deef 100644 (file)
@@ -525,8 +525,6 @@ _tbm_surface_queue_init(tbm_surface_queue_h surface_queue,
        TBM_RETURN_IF_FAIL(surface_queue != NULL);
        TBM_RETURN_IF_FAIL(impl != NULL);
 
-       memset(surface_queue, 0x00, sizeof(struct _tbm_surface_queue));
-
        if (!g_surf_queue_bufmgr)
                _init_tbm_surf_queue_bufmgr();
 
@@ -546,9 +544,9 @@ _tbm_surface_queue_init(tbm_surface_queue_h surface_queue,
        LIST_INITHEAD(&surface_queue->list);
 
        LIST_INITHEAD(&surface_queue->destory_noti);
-       LIST_INITHEAD(&surface_queue->acquirable_noti);
        LIST_INITHEAD(&surface_queue->dequeuable_noti);
        LIST_INITHEAD(&surface_queue->dequeue_noti);
+       LIST_INITHEAD(&surface_queue->acquirable_noti);
        LIST_INITHEAD(&surface_queue->reset_noti);
 
        if (surface_queue->impl && surface_queue->impl->init)
@@ -1227,6 +1225,8 @@ tbm_surface_queue_destroy(tbm_surface_queue_h surface_queue)
 
        TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
 
+       LIST_DEL(&surface_queue->item_link);
+
        LIST_FOR_EACH_ENTRY_SAFE(node, tmp, &surface_queue->list, link)
                _queue_delete_node(surface_queue, node);
 
@@ -1236,16 +1236,14 @@ tbm_surface_queue_destroy(tbm_surface_queue_h surface_queue)
        _notify_emit(surface_queue, &surface_queue->destory_noti);
 
        _notify_remove_all(&surface_queue->destory_noti);
-       _notify_remove_all(&surface_queue->acquirable_noti);
        _notify_remove_all(&surface_queue->dequeuable_noti);
+       _notify_remove_all(&surface_queue->dequeue_noti);
+       _notify_remove_all(&surface_queue->acquirable_noti);
        _notify_remove_all(&surface_queue->reset_noti);
 
        pthread_mutex_destroy(&surface_queue->lock);
 
-       LIST_DEL(&surface_queue->item_link);
-
        free(surface_queue);
-       surface_queue = NULL;
 
        if (LIST_IS_EMPTY(&g_surf_queue_bufmgr->surf_queue_list))
                _deinit_tbm_surf_queue_bufmgr();