[svn] ksba - r261 - trunk/src
svn author marcus
cvs at cvs.gnupg.org
Mon Dec 18 02:04:04 CET 2006
Author: marcus
Date: 2006-12-18 02:04:02 +0100 (Mon, 18 Dec 2006)
New Revision: 261
Modified:
trunk/src/ChangeLog
trunk/src/asn1-func.c
trunk/src/asn1-func2.c
trunk/src/asn1-parse.y
trunk/src/ber-decoder.c
trunk/src/cert.c
Log:
2006-12-18 Marcus Brinkmann <marcus at g10code.de>
* cert.c (ksba_cert_release): Release cert->root and
cert->asn_tree.
(ksba_cert_read_der): Release cert->root and cert->asn_tree.
* ber-decoder.c (_ksba_ber_decoder_decode): Release d->root.
* asn1-func.c (do_expand_tree): Keep track of created nodes.
(copy_tree): Likewise.
(_ksba_asn_insert_copy): Likewise.
(ksba_asn_tree_dump): Release tree if expanded.
* asn1-func2.c (ksba_asn_create_tree): Keep track of created
nodes.
* asn1-parse.y (new_node): Fix assignment.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2006-11-29 20:04:27 UTC (rev 260)
+++ trunk/src/ChangeLog 2006-12-18 01:04:02 UTC (rev 261)
@@ -1,3 +1,17 @@
+2006-12-18 Marcus Brinkmann <marcus at g10code.de>
+
+ * cert.c (ksba_cert_release): Release cert->root and
+ cert->asn_tree.
+ (ksba_cert_read_der): Release cert->root and cert->asn_tree.
+ * ber-decoder.c (_ksba_ber_decoder_decode): Release d->root.
+ * asn1-func.c (do_expand_tree): Keep track of created nodes.
+ (copy_tree): Likewise.
+ (_ksba_asn_insert_copy): Likewise.
+ (ksba_asn_tree_dump): Release tree if expanded.
+ * asn1-func2.c (ksba_asn_create_tree): Keep track of created
+ nodes.
+ * asn1-parse.y (new_node): Fix assignment.
+
2006-11-29 Werner Koch <wk at g10code.com>
* ocsp.c (parse_single_response): Fixed skipping of the NULL.
Modified: trunk/src/asn1-func.c
===================================================================
--- trunk/src/asn1-func.c 2006-11-29 20:04:27 UTC (rev 260)
+++ trunk/src/asn1-func.c 2006-12-18 01:04:02 UTC (rev 261)
@@ -634,7 +634,8 @@
}
}
- /* FIXME: release the tree if expanded */
+ if (expand)
+ _ksba_asn_release_nodes (root);
}
int
@@ -997,12 +998,16 @@
copy_tree (AsnNode src_root, AsnNode s)
{
AsnNode first=NULL, dprev=NULL, d, down, tmp;
+ AsnNode *link_nextp = NULL;
for (; s; s=s->right )
{
down = s->down;
d = copy_node (s);
-
+ if (link_nextp)
+ *link_nextp = d;
+ link_nextp = &d->link_next;
+
if (!first)
first = d;
else
@@ -1014,6 +1019,15 @@
if (down)
{
tmp = copy_tree (src_root, down);
+ if (tmp)
+ {
+ if (link_nextp)
+ *link_nextp = tmp;
+ link_nextp = &tmp->link_next;
+ while (*link_nextp)
+ link_nextp = &(*link_nextp)->link_next;
+ }
+
if (d->down && tmp)
{ /* Need to merge it with the existing down */
AsnNode x;
@@ -1063,6 +1077,7 @@
do_expand_tree (AsnNode src_root, AsnNode s, int depth)
{
AsnNode first=NULL, dprev=NULL, d, down, tmp;
+ AsnNode *link_nextp = NULL;
/* On the very first level we do not follow the right pointer so that
we can break out a valid subtree. */
@@ -1085,6 +1100,9 @@
}
down = d->down;
d = copy_node (d);
+ if (link_nextp)
+ *link_nextp = d;
+ link_nextp = &d->link_next;
if (s->flags.is_optional)
d->flags.is_optional = 1;
if (s->flags.in_choice)
@@ -1105,6 +1123,9 @@
AsnNode x;
x = copy_node (s2);
+ if (link_nextp)
+ *link_nextp = x;
+ link_nextp = &x->link_next;
x->left = *dp? *dp : d;
*dp = x;
dp = &(*dp)->right;
@@ -1117,7 +1138,12 @@
d->down = tmp;
}
else
- d = copy_node (s);
+ {
+ d = copy_node (s);
+ if (link_nextp)
+ *link_nextp = d;
+ link_nextp = &d->link_next;
+ }
if (!first)
first = d;
@@ -1135,7 +1161,17 @@
tmp = NULL;
}
else
- tmp = do_expand_tree (src_root, down, depth+1);
+ {
+ tmp = do_expand_tree (src_root, down, depth+1);
+ if (tmp)
+ {
+ if (link_nextp)
+ *link_nextp = tmp;
+ link_nextp = &tmp->link_next;
+ while (*link_nextp)
+ link_nextp = &(*link_nextp)->link_next;
+ }
+ }
if (d->down && tmp)
{ /* Need to merge it with the existing down */
AsnNode x;
@@ -1153,6 +1189,7 @@
}
}
}
+
return first;
}
@@ -1179,6 +1216,7 @@
_ksba_asn_insert_copy (AsnNode node)
{
AsnNode n;
+ AsnNode *link_nextp;
n = copy_tree (node, node);
if (!n)
@@ -1186,7 +1224,13 @@
return_null_if_fail (n->right == node->right);
node->right = n;
n->left = node;
-
+
+ /* FIXME: Consider tail pointer for faster insertion. */
+ link_nextp = &node->link_next;
+ while (*link_nextp)
+ link_nextp = &(*link_nextp)->link_next;
+ *link_nextp = n;
+
return n;
}
Modified: trunk/src/asn1-func2.c
===================================================================
--- trunk/src/asn1-func2.c 2006-11-29 20:04:27 UTC (rev 260)
+++ trunk/src/asn1-func2.c 2006-12-18 01:04:02 UTC (rev 261)
@@ -105,9 +105,12 @@
{
enum { DOWN, UP, RIGHT } move;
const static_asn *root;
- AsnNode pointer, p, p_last = NULL;
+ AsnNode pointer;
+ AsnNode p = NULL;
+ AsnNode p_last = NULL;
unsigned long k;
int rc;
+ AsnNode link_next = NULL;
if (!result)
return gpg_error (GPG_ERR_INV_VALUE);
@@ -128,6 +131,9 @@
p = _ksba_asn_new_node (root[k].type);
p->flags = root[k].flags;
p->flags.help_down = 0;
+ p->link_next = link_next;
+ link_next = p;
+
if (root[k].name)
_ksba_asn_set_name (p, root[k].name);
if (root[k].stringvalue)
@@ -191,7 +197,7 @@
else
{
tree->parse_tree = pointer;
- tree->node_list = NULL; /* fixme: should release the memory */
+ tree->node_list = p;
strcpy (tree->filename, mod_name);
*result = tree;
rc = 0;
Modified: trunk/src/asn1-parse.y
===================================================================
--- trunk/src/asn1-parse.y 2006-11-29 20:04:27 UTC (rev 260)
+++ trunk/src/asn1-parse.y 2006-12-18 01:04:02 UTC (rev 261)
@@ -889,7 +889,7 @@
node->type = type;
node->off = -1;
node->link_next = parsectl->all_nodes;
- parsectl->all_nodes = node->link_next;
+ parsectl->all_nodes = node;
return node;
}
Modified: trunk/src/ber-decoder.c
===================================================================
--- trunk/src/ber-decoder.c 2006-11-29 20:04:27 UTC (rev 260)
+++ trunk/src/ber-decoder.c 2006-12-18 01:04:02 UTC (rev 261)
@@ -768,7 +768,7 @@
decoder_next (BerDecoder d)
{
struct tag_info ti;
- AsnNode node = NULL;
+ AsnNode node;
gpg_error_t err;
DECODER_STATE ds = d->ds;
int debug = d->debug;
@@ -1206,7 +1206,7 @@
{
if (!d->image.buf)
{ /* Not even the first node available - return eof */
- /* Fixme: release d->root */
+ _ksba_asn_release_nodes (d->root);
d->root = NULL;
err = gpg_error (GPG_ERR_EOF);
}
Modified: trunk/src/cert.c
===================================================================
--- trunk/src/cert.c 2006-11-29 20:04:27 UTC (rev 260)
+++ trunk/src/cert.c 2006-12-18 01:04:02 UTC (rev 261)
@@ -119,8 +119,9 @@
xfree (cert->cache.extns);
}
-
- /* FIXME: release cert->root, ->asn_tree */
+ _ksba_asn_release_nodes (cert->root);
+ ksba_asn_tree_release (cert->asn_tree);
+
xfree (cert);
}
@@ -261,7 +262,10 @@
if (cert->initialized)
return gpg_error (GPG_ERR_CONFLICT); /* Fixme: should remove the old one */
- /* fixme: clear old cert->root */
+ _ksba_asn_release_nodes (cert->root);
+ ksba_asn_tree_release (cert->asn_tree);
+ cert->root = NULL;
+ cert->asn_tree = NULL;
err = ksba_asn_create_tree ("tmttv2", &cert->asn_tree);
if (err)
More information about the Gnupg-commits
mailing list