gril: Add parcel_r_strv

This commit is contained in:
Denis Kenzior 2015-12-01 11:26:35 -06:00
parent 82f72d288b
commit f98d2aa282
2 changed files with 23 additions and 0 deletions

View File

@ -312,3 +312,25 @@ void parcel_free_str_array(struct parcel_str_array *str_arr)
g_free(str_arr);
}
}
char **parcel_r_strv(struct parcel *p)
{
int i;
int num_str = parcel_r_int32(p);
char **strv;
if (p->malformed || num_str <= 0)
return NULL;
strv = g_new0(char *, num_str + 1);
for (i = 0; i < num_str; i++)
strv[i] = parcel_r_string(p);
if (p->malformed) {
g_strfreev(strv);
strv = NULL;
}
return strv;
}

View File

@ -50,5 +50,6 @@ void *parcel_r_raw(struct parcel *p, int *len);
size_t parcel_data_avail(struct parcel *p);
struct parcel_str_array *parcel_r_str_array(struct parcel *p);
void parcel_free_str_array(struct parcel_str_array *str_arr);
char **parcel_r_strv(struct parcel *p);
#endif