Helper function to walk through keydata chained blocks.

This commit is contained in:
Giovanni Bajo
2012-04-27 03:11:03 +02:00
committed by Simon Kelley
parent a7338645d7
commit 458824dcb4
2 changed files with 18 additions and 0 deletions

View File

@@ -1364,6 +1364,23 @@ struct keydata *keydata_alloc(char *data, size_t len)
return ret;
}
size_t keydata_walk(struct keydata **key, unsigned char **p, size_t cnt)
{
size_t ret;
if (*p == NULL)
*p = (*key)->key;
else if (*p == (*key)->key + KEYBLOCK_LEN)
{
*key = (*key)->next;
if (*key == NULL)
return 0;
*p = (*key)->key;
}
return MIN(cnt, (*key)->key + KEYBLOCK_LEN - (*p));
}
void keydata_free(struct keydata *blocks)
{
struct keydata *tmp;