stkutil: Use l_queue instead of GSList

This commit is contained in:
Denis Kenzior 2018-12-28 13:48:34 -06:00
parent 4927905db4
commit 22002d142c
3 changed files with 31 additions and 31 deletions

View File

@ -345,15 +345,15 @@ static char *dbus_apply_text_attributes(const char *text,
}
static struct stk_menu *stk_menu_create(const char *title,
const struct stk_text_attribute *title_attr,
const struct stk_icon_id *icon, GSList *items,
const struct stk_item_text_attribute_list *item_attrs,
const struct stk_item_icon_id_list *item_icon_ids,
int default_id, gboolean soft_key, gboolean has_help)
const struct stk_text_attribute *title_attr,
const struct stk_icon_id *icon, struct l_queue *items,
const struct stk_item_text_attribute_list *item_attrs,
const struct stk_item_icon_id_list *item_icon_ids,
int default_id, bool soft_key, bool has_help)
{
unsigned int len = g_slist_length(items);
unsigned int len = l_queue_length(items);
struct stk_menu *ret;
GSList *l;
const struct l_queue_entry *entry;
int i;
struct stk_text_attribute attr;
@ -378,8 +378,9 @@ static struct stk_menu *stk_menu_create(const char *title,
ret->soft_key = soft_key;
ret->has_help = has_help;
for (l = items, i = 0; l; l = l->next, i++) {
struct stk_item *item = l->data;
for (entry = l_queue_get_entries(items), i = 0;
entry; entry = entry->next, i++) {
struct stk_item *item = entry->data;
char *text;
ret->items[i].item_id = item->id;

View File

@ -2231,42 +2231,39 @@ static void destroy_stk_item(gpointer pointer)
static gboolean parse_item_list(struct comprehension_tlv_iter *iter,
void *data)
{
GSList **out = data;
unsigned short tag = STK_DATA_OBJECT_TYPE_ITEM;
struct l_queue **out = data;
uint16_t tag = STK_DATA_OBJECT_TYPE_ITEM;
struct comprehension_tlv_iter iter_old;
struct stk_item item;
GSList *list = NULL;
struct l_queue *list = l_queue_new();
unsigned int count = 0;
gboolean has_empty = FALSE;
bool has_empty = FALSE;
do {
comprehension_tlv_iter_copy(iter, &iter_old);
memset(&item, 0, sizeof(item));
count++;
if (parse_dataobj_item(iter, &item) == TRUE) {
if (item.id == 0) {
has_empty = TRUE;
continue;
}
if (!parse_dataobj_item(iter, &item))
continue;
list = g_slist_prepend(list,
l_memdup(&item, sizeof(item)));
if (item.id == 0) {
has_empty = TRUE;
continue;
}
l_queue_push_tail(list, l_memdup(&item, sizeof(item)));
} while (comprehension_tlv_iter_next(iter) == TRUE &&
comprehension_tlv_iter_get_tag(iter) == tag);
comprehension_tlv_iter_copy(&iter_old, iter);
if (!has_empty) {
*out = g_slist_reverse(list);
if (!has_empty || count == 1) {
*out = list;
return TRUE;
}
if (count == 1)
return TRUE;
g_slist_free_full(list, destroy_stk_item);
l_queue_destroy(list, destroy_stk_item);
return FALSE;
}
@ -2590,7 +2587,7 @@ static enum stk_command_parse_result parse_poll_interval(
static void destroy_setup_menu(struct stk_command *command)
{
l_free(command->setup_menu.alpha_id);
g_slist_free_full(command->setup_menu.items, destroy_stk_item);
l_queue_destroy(command->setup_menu.items, destroy_stk_item);
}
static enum stk_command_parse_result parse_setup_menu(
@ -2635,7 +2632,7 @@ static enum stk_command_parse_result parse_setup_menu(
static void destroy_select_item(struct stk_command *command)
{
l_free(command->select_item.alpha_id);
g_slist_free_full(command->select_item.items, destroy_stk_item);
l_queue_destroy(command->select_item.items, destroy_stk_item);
}
static enum stk_command_parse_result parse_select_item(
@ -2675,7 +2672,7 @@ static enum stk_command_parse_result parse_select_item(
command->destructor = destroy_select_item;
if (status == STK_PARSE_RESULT_OK && obj->items == NULL)
if (status == STK_PARSE_RESULT_OK && l_queue_isempty(obj->items))
status = STK_PARSE_RESULT_DATA_NOT_UNDERSTOOD;
CHECK_TEXT_AND_ICON(obj->alpha_id, obj->icon_id.id);

View File

@ -19,6 +19,8 @@
*
*/
struct l_queue;
/*
* TS 101.220, Section 7.2, Card Application Toolkit assigned templates,
* These are the same as 3GPP 11.14 Sections 13.1 and 13.2
@ -1177,7 +1179,7 @@ struct stk_command_poll_interval {
struct stk_command_setup_menu {
char *alpha_id;
GSList *items;
struct l_queue *items;
struct stk_items_next_action_indicator next_act;
struct stk_icon_id icon_id;
struct stk_item_icon_id_list item_icon_id_list;
@ -1187,7 +1189,7 @@ struct stk_command_setup_menu {
struct stk_command_select_item {
char *alpha_id;
GSList *items;
struct l_queue *items;
struct stk_items_next_action_indicator next_act;
unsigned char item_id;
struct stk_icon_id icon_id;