summaryrefslogtreecommitdiff
path: root/lib/element.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/element.c')
-rw-r--r--lib/element.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/element.c b/lib/element.c
index 7976285..dceb8ba 100644
--- a/lib/element.c
+++ b/lib/element.c
@@ -132,14 +132,14 @@ _asn1_convert_integer (const unsigned char *value, unsigned char *value_out,
* node. The new element will have a name of '?number', where number
* is a monotonically increased serial number.
*
- * The last element in the list may be provided in @ptail, to avoid
+ * The last element in the list may be provided in @pcache, to avoid
* traversing the list, an expensive operation in long lists.
*
- * On success it returns in @ptail the added element (which is the
+ * On success it returns in @pcache the added element (which is the
* tail in the list of added elements).
*/
int
-_asn1_append_sequence_set (asn1_node node, asn1_node *ptail)
+_asn1_append_sequence_set (asn1_node node, struct node_tail_cache_st *pcache)
{
asn1_node p, p2;
char temp[LTOSTR_MAX_SIZE];
@@ -154,7 +154,7 @@ _asn1_append_sequence_set (asn1_node node, asn1_node *ptail)
p = p->right;
p2 = _asn1_copy_structure3 (p);
- if (ptail == NULL || *ptail == NULL)
+ if (pcache == NULL || pcache->tail == NULL || pcache->head != node)
{
while (p->right)
{
@@ -163,12 +163,15 @@ _asn1_append_sequence_set (asn1_node node, asn1_node *ptail)
}
else
{
- p = *ptail;
+ p = pcache->tail;
}
_asn1_set_right (p, p2);
- if (ptail)
- *ptail = p2;
+ if (pcache)
+ {
+ pcache->head = node;
+ pcache->tail = p2;
+ }
if (p->name[0] == 0)
_asn1_str_cpy (temp, sizeof (temp), "?1");