Index: main/utils.c =================================================================== --- main/utils.c (revision 89536) +++ main/utils.c (working copy) @@ -704,12 +704,8 @@ static int handle_show_locks(int fd, int argc, char *argv[]) { struct thr_lock_info *lock_info; - struct ast_dynamic_str *str; - if (!(str = ast_dynamic_str_create(4096))) - return RESULT_FAILURE; - - ast_dynamic_str_append(&str, 0, "\n" + ast_cli(fd, "\n" "=======================================================================\n" "=== Currently Held Locks ==============================================\n" "=======================================================================\n" @@ -723,14 +719,14 @@ pthread_mutex_lock(&lock_infos_lock.mutex); AST_LIST_TRAVERSE(&lock_infos, lock_info, entry) { int i; - ast_dynamic_str_append(&str, 0, "=== Thread ID: %u (%s)\n", (int) lock_info->thread_id, + ast_cli(fd, "=== Thread ID: %u (%s)\n", (int) lock_info->thread_id, lock_info->thread_name); pthread_mutex_lock(&lock_info->lock); - for (i = 0; str && i < lock_info->num_locks; i++) { + for (i = 0; i < lock_info->num_locks; i++) { int j; ast_mutex_t *lock; - ast_dynamic_str_append(&str, 0, "=== ---> %sLock #%d (%s): %s %d %s %s %p (%d)\n", + ast_cli(fd, "=== ---> %sLock #%d (%s): %s %d %s %s %p (%d)\n", lock_info->locks[i].pending > 0 ? "Waiting for " : lock_info->locks[i].pending < 0 ? "Tried and failed to get " : "", i, lock_info->locks[i].file, @@ -746,35 +742,21 @@ lock = lock_info->locks[i].lock_addr; ast_reentrancy_lock(lock); - for (j = 0; str && j < lock->reentrancy; j++) { - ast_dynamic_str_append(&str, 0, "=== --- ---> Locked Here: %s line %d (%s)\n", + for (j = 0; j < lock->reentrancy; j++) { + ast_cli(fd, "=== --- ---> Locked Here: %s line %d (%s)\n", lock->file[j], lock->lineno[j], lock->func[j]); } ast_reentrancy_unlock(lock); } pthread_mutex_unlock(&lock_info->lock); - if (!str) - break; - ast_dynamic_str_append(&str, 0, "=== -------------------------------------------------------------------\n" + ast_cli(fd, "=== -------------------------------------------------------------------\n" "===\n"); - if (!str) - break; } pthread_mutex_unlock(&lock_infos_lock.mutex); - if (!str) - return RESULT_FAILURE; - - ast_dynamic_str_append(&str, 0, "=======================================================================\n" + ast_cli(fd, "=======================================================================\n" "\n"); - if (!str) - return RESULT_FAILURE; - - ast_cli(fd, "%s", str->str); - - free(str); - return RESULT_SUCCESS; }