- Add scconf_list_toarray() by Jamie Honan

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1617 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
aet 2003-11-20 14:13:08 +00:00
parent 0b7b3dff9c
commit c13a417d8b
2 changed files with 31 additions and 0 deletions

View File

@ -366,6 +366,30 @@ int scconf_list_strings_length(const scconf_list * list)
return len;
}
const char **scconf_list_toarray(const scconf_list * list)
{
const scconf_list * lp = list;
const char **tp;
int len = 0;
while (lp) {
len++;
lp = lp->next;
}
tp = (const char **)malloc(sizeof(char *) * (len + 1));
if (!tp)
return tp;
lp = list;
len = 0;
while (lp) {
tp[len] = lp->data;
len++;
lp = lp->next;
}
tp[len] = NULL;
return tp;
}
char *scconf_list_strdup(const scconf_list * list, const char *filler)
{
char *buf = NULL;

View File

@ -213,6 +213,13 @@ extern int scconf_list_strings_length(const scconf_list * list);
*/
extern char *scconf_list_strdup(const scconf_list * list, const char *filler);
/* Returns an allocated array of const char *pointers to
* list elements.
* Last pointer is NULL
* Array must be freed, but pointers to strings belong to scconf_list
*/
extern const char **scconf_list_toarray(const scconf_list * list);
#ifdef __cplusplus
}
#endif