stkutil: Refactor struct stk_frames_info

This commit is contained in:
Andrzej Zaborowski 2010-06-11 12:39:49 +02:00 committed by Denis Kenzior
parent 6e4277eef8
commit fb39e0efed
2 changed files with 12 additions and 3 deletions

View File

@ -1628,6 +1628,7 @@ static gboolean parse_dataobj_frames_info(struct comprehension_tlv_iter *iter,
struct stk_frames_info *fi = user;
const unsigned char *data;
unsigned char len = comprehension_tlv_iter_get_length(iter);
unsigned int i;
if (len < 1)
return FALSE;
@ -1640,12 +1641,18 @@ static gboolean parse_dataobj_frames_info(struct comprehension_tlv_iter *iter,
if ((len == 1 && data[0] != 0) || (len > 1 && data[0] == 0))
return FALSE;
if (len % 2 == 0)
return FALSE;
if (len == 1)
return TRUE;
fi->id = data[0];
fi->len = len - 1;
memcpy(fi->list, data + 1, fi->len);
fi->len = (len - 1) / 2;
for (i = 0; i < len; i++) {
fi->list[i].height = data[i * 2 + 1] & 0x1f;
fi->list[i].width = data[i * 2 + 2] & 0x7f;
}
return TRUE;
}

View File

@ -813,7 +813,9 @@ struct stk_frame_layout {
*/
struct stk_frames_info {
unsigned char id;
unsigned char list[126];
struct {
unsigned char width, height;
} list[63];
unsigned int len;
};