return tbm_last_error;
}
-void
-tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr, char *str, int *len)
+char *
+tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr)
{
char app_name[255] = {0,}, title[512] = {0,};
tbm_surface_debug_data *debug_old_data = NULL;
+ char *str;
+ int len = 1024*4;
+ int c = 0;
pthread_mutex_lock(&gLock);
if (!TBM_BUFMGR_IS_VALID(bufmgr) || (bufmgr != gBufMgr)) {
TBM_LOG_E("invalid bufmgr\n");
pthread_mutex_unlock(&gLock);
- return;
+ return NULL;
+ }
+
+ str = malloc(len);
+ if (!str) {
+ TBM_LOG_E("Fail to allocate the string.\n");
+ pthread_mutex_unlock(&gLock);
+ return NULL;
}
- TBM_SNPRINTF(str, len, "\n");
+ TBM_SNRPRINTF(str, len, c, "\n");
_tbm_util_get_appname_from_pid(getpid(), app_name);
_tbm_util_get_appname_brief(app_name);
- TBM_SNPRINTF(str, len, "============TBM DEBUG: %s(%d)===========================\n",
+ TBM_SNRPRINTF(str, len, c, "============TBM DEBUG: %s(%d)===========================\n",
app_name, getpid());
snprintf(title, 255, "%s", "no surface refcnt width height bpp size n_b n_p flags format app_name ");
}
}
- TBM_SNPRINTF(str, len, "[tbm_surface information]\n");
- TBM_SNPRINTF(str, len, "%s\n", title);
+ TBM_SNRPRINTF(str, len, c, "[tbm_surface information]\n");
+ TBM_SNRPRINTF(str, len, c, "%s\n", title);
/* show the tbm_surface information in surf_list */
if (!LIST_IS_EMPTY(&bufmgr->surf_list)) {
strncat(data, "none", MAX_SIZE_N(title));
}
}
- TBM_SNPRINTF(str, len, "%s\n", data);
+ TBM_SNRPRINTF(str, len, c, "%s\n", data);
for (i = 0; i < surf->num_bos; i++) {
- TBM_SNPRINTF(str, len, " bo:%-12p %-26d%-10d\n",
+ TBM_SNRPRINTF(str, len, c, " bo:%-12p %-26d%-10d\n",
surf->bos[i],
surf->bos[i]->ref_cnt,
bufmgr->backend->bo_size(surf->bos[i]) / 1024);
}
}
} else
- TBM_SNPRINTF(str, len, " no tbm_surfaces.\n");
- TBM_SNPRINTF(str, len, "\n");
+ TBM_SNRPRINTF(str, len, c, " no tbm_surfaces.\n");
+ TBM_SNRPRINTF(str, len, c, "\n");
- TBM_SNPRINTF(str, len, "[tbm_bo information]\n");
- TBM_SNPRINTF(str, len, "no bo refcnt size lock_cnt map_cnt flags surface name\n");
+ TBM_SNRPRINTF(str, len, c, "[tbm_bo information]\n");
+ TBM_SNRPRINTF(str, len, c, "no bo refcnt size lock_cnt map_cnt flags surface name\n");
/* show the tbm_bo information in bo_list */
if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
tbm_bo bo = NULL;
LIST_FOR_EACH_ENTRY(bo, &bufmgr->bo_list, item_link) {
- TBM_SNPRINTF(str, len, "%-4d%-11p %-4d %-6d %-5d %-4u %-3d %-11p %-4d\n",
+ TBM_SNRPRINTF(str, len, c, "%-4d%-11p %-4d %-6d %-5d %-4u %-3d %-11p %-4d\n",
++bo_cnt,
bo,
bo->ref_cnt,
tbm_bo_export(bo));
}
} else
- TBM_SNPRINTF(str, len, "no tbm_bos.\n");
- TBM_SNPRINTF(str, len, "\n");
+ TBM_SNRPRINTF(str, len, c, "no tbm_bos.\n");
+ TBM_SNRPRINTF(str, len, c, "\n");
- TBM_SNPRINTF(str, len, "===============================================================\n");
+ TBM_SNRPRINTF(str, len, c, "===============================================================\n");
pthread_mutex_unlock(&gLock);
+
+ return str;
}
void
tbm_bufmgr_debug_show(tbm_bufmgr bufmgr)
{
- char str[1024*4];
- int len = sizeof(str);
- tbm_bufmgr_debug_tbm_info_get(bufmgr, str, &len);
- TBM_DEBUG(" %s", str);
+ char * str;
+ str = tbm_bufmgr_debug_tbm_info_get(bufmgr);
+ if (str) {
+ TBM_DEBUG(" %s", str);
+ free(str);
+ }
}
void