summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2016-04-03 10:10:49 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2016-04-03 11:36:44 +0200
commit62cb6fab75ee9a4fc2925104896980d40862a89f (patch)
tree43038d570af994ba87981edfc78a93690b671fe3
parent56b9f13cff50861bc0660dcf5b8d4a41c2bd5289 (diff)
downloadlibtasn1-62cb6fab75ee9a4fc2925104896980d40862a89f.tar.gz
Revert "optimized _asn1_find_up()."
This reverts commit 4010bb04588fca86a9f6d683b637c05b4cec24e0. This optimization did not offer much benefit and there may be corner cases in the internal structure handling that may not be possibly to handle with this optimization.
-rw-r--r--lib/coding.c4
-rw-r--r--lib/decoding.c20
-rw-r--r--lib/element.c11
-rw-r--r--lib/int.h1
-rw-r--r--lib/parser_aux.c18
-rw-r--r--lib/parser_aux.h13
-rw-r--r--lib/structure.c22
7 files changed, 38 insertions, 51 deletions
diff --git a/lib/coding.c b/lib/coding.c
index 78615a1..0c0f69c 100644
--- a/lib/coding.c
+++ b/lib/coding.c
@@ -1253,7 +1253,7 @@ asn1_der_coding (asn1_node element, const char *name, void *ider, int *len,
continue;
}
else
- p = _asn1_get_up (p);
+ p = _asn1_find_up (p);
move = UP;
}
if (move == UP)
@@ -1328,7 +1328,7 @@ asn1_der_coding (asn1_node element, const char *name, void *ider, int *len,
move = UP;
}
if (move == UP)
- p = _asn1_get_up (p);
+ p = _asn1_find_up (p);
}
*len = counter;
diff --git a/lib/decoding.c b/lib/decoding.c
index caf1eb4..7a86182 100644
--- a/lib/decoding.c
+++ b/lib/decoding.c
@@ -710,7 +710,7 @@ _asn1_delete_not_used (asn1_node node)
{
p2 = _asn1_find_left (p);
if (!p2)
- p2 = _asn1_get_up (p);
+ p2 = _asn1_find_up (p);
}
asn1_delete_structure (&p);
p = p2;
@@ -733,7 +733,7 @@ _asn1_delete_not_used (asn1_node node)
{
while (1)
{
- p = _asn1_get_up (p);
+ p = _asn1_find_up (p);
if (p == node)
{
p = NULL;
@@ -1050,7 +1050,7 @@ asn1_der_decoding2 (asn1_node *element, const void *ider, int *max_ider_len,
{
if (p->type & CONST_SET)
{
- p2 = _asn1_get_up (p);
+ p2 = _asn1_find_up (p);
len2 = p2->tmp_ival;
if (len2 == -1)
{
@@ -1106,7 +1106,7 @@ asn1_der_decoding2 (asn1_node *element, const void *ider, int *max_ider_len,
if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
{
- p2 = _asn1_get_up (p);
+ p2 = _asn1_find_up (p);
len2 = p2->tmp_ival;
if (counter == len2)
{
@@ -1169,7 +1169,7 @@ asn1_der_decoding2 (asn1_node *element, const void *ider, int *max_ider_len,
if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
{
- p2 = _asn1_get_up (p);
+ p2 = _asn1_find_up (p);
len2 = p2->tmp_ival;
if ((len2 != -1) && (counter > len2))
@@ -1597,7 +1597,7 @@ asn1_der_decoding2 (asn1_node *element, const void *ider, int *max_ider_len,
move = UP;
}
if (move == UP)
- p = _asn1_get_up (p);
+ p = _asn1_find_up (p);
}
_asn1_delete_not_used (*element);
@@ -1810,7 +1810,7 @@ asn1_expand_any_defined_by (asn1_node definitions, asn1_node * element)
break;
}
- p3 = _asn1_get_up (p);
+ p3 = _asn1_find_up (p);
if (!p3)
{
@@ -1830,8 +1830,8 @@ asn1_expand_any_defined_by (asn1_node definitions, asn1_node * element)
(p3->value == NULL))
{
- p3 = _asn1_get_up (p);
- p3 = _asn1_get_up (p3);
+ p3 = _asn1_find_up (p);
+ p3 = _asn1_find_up (p3);
if (!p3)
{
@@ -1966,7 +1966,7 @@ asn1_expand_any_defined_by (asn1_node definitions, asn1_node * element)
{
while (1)
{
- p = _asn1_get_up (p);
+ p = _asn1_find_up (p);
if (p == *element)
{
p = NULL;
diff --git a/lib/element.c b/lib/element.c
index 321302a..7976285 100644
--- a/lib/element.c
+++ b/lib/element.c
@@ -52,7 +52,7 @@ _asn1_hierarchical_name (asn1_node node, char *name, int name_size)
_asn1_str_cat (name, name_size, ".");
_asn1_str_cat (name, name_size, tmp_name);
}
- p = _asn1_get_up (p);
+ p = _asn1_find_up (p);
}
if (name[0] == 0)
@@ -154,9 +154,12 @@ _asn1_append_sequence_set (asn1_node node, asn1_node *ptail)
p = p->right;
p2 = _asn1_copy_structure3 (p);
- if (ptail == NULL || *ptail == NULL || (*ptail)->up != p->up)
- while (p->right) {
- p = p->right;
+ if (ptail == NULL || *ptail == NULL)
+ {
+ while (p->right)
+ {
+ p = p->right;
+ }
}
else
{
diff --git a/lib/int.h b/lib/int.h
index ee870c7..322b80f 100644
--- a/lib/int.h
+++ b/lib/int.h
@@ -51,7 +51,6 @@ struct asn1_node_st
unsigned int type; /* Node type */
unsigned char *value; /* Node value */
int value_len;
- asn1_node up; /* Pointer to the parent node */
asn1_node down; /* Pointer to the son node */
asn1_node right; /* Pointer to the brother node */
asn1_node left; /* Pointer to the next list element */
diff --git a/lib/parser_aux.c b/lib/parser_aux.c
index da9a388..8e85bf8 100644
--- a/lib/parser_aux.c
+++ b/lib/parser_aux.c
@@ -425,11 +425,7 @@ _asn1_set_right (asn1_node node, asn1_node right)
return node;
node->right = right;
if (right)
- {
- right->left = node;
- if (right->up == NULL)
- right->up = node->up;
- }
+ right->left = node;
return node;
}
@@ -625,7 +621,7 @@ _asn1_change_integer_value (asn1_node node)
{
while (1)
{
- p = _asn1_get_up (p);
+ p = _asn1_find_up (p);
if (p == node)
{
p = NULL;
@@ -753,7 +749,7 @@ _asn1_expand_object_id (asn1_node node)
move = UP;
}
if (move == UP)
- p = _asn1_get_up (p);
+ p = _asn1_find_up (p);
}
@@ -825,7 +821,7 @@ _asn1_expand_object_id (asn1_node node)
move = UP;
}
if (move == UP)
- p = _asn1_get_up (p);
+ p = _asn1_find_up (p);
}
return ASN1_SUCCESS;
@@ -895,7 +891,7 @@ _asn1_type_set_config (asn1_node node)
move = UP;
}
if (move == UP)
- p = _asn1_get_up (p);
+ p = _asn1_find_up (p);
}
return ASN1_SUCCESS;
@@ -992,7 +988,7 @@ _asn1_check_identifier (asn1_node node)
{
while (1)
{
- p = _asn1_get_up (p);
+ p = _asn1_find_up (p);
if (p == node)
{
p = NULL;
@@ -1052,7 +1048,7 @@ _asn1_set_default_tag (asn1_node node)
{
while (1)
{
- p = _asn1_get_up (p);
+ p = _asn1_find_up (p);
if (p == node)
{
p = NULL;
diff --git a/lib/parser_aux.h b/lib/parser_aux.h
index 437f1c8..10b864b 100644
--- a/lib/parser_aux.h
+++ b/lib/parser_aux.h
@@ -58,14 +58,6 @@ char *_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE]);
asn1_node _asn1_find_up (asn1_node node);
-inline static asn1_node _asn1_get_up(asn1_node node)
-{
- if (node && node->up)
- return node->up;
- else
- return _asn1_find_up(node);
-}
-
int _asn1_change_integer_value (asn1_node node);
int _asn1_expand_object_id (asn1_node node);
@@ -108,10 +100,7 @@ _asn1_set_down (asn1_node node, asn1_node down)
return node;
node->down = down;
if (down)
- {
- down->left = node;
- down->up = node;
- }
+ down->left = node;
return node;
}
diff --git a/lib/structure.c b/lib/structure.c
index fc33547..01715b1 100644
--- a/lib/structure.c
+++ b/lib/structure.c
@@ -134,7 +134,7 @@ _asn1_create_static_structure (asn1_node pointer, char *output_file_name,
{
while (1)
{
- p = _asn1_get_up (p);
+ p = _asn1_find_up (p);
if (p == pointer)
{
p = NULL;
@@ -223,7 +223,7 @@ asn1_array2tree (const asn1_static_node * array, asn1_node * definitions,
if (p_last == *definitions)
break;
- p_last = _asn1_get_up (p_last);
+ p_last = _asn1_find_up (p_last);
if (p_last == NULL)
break;
@@ -323,7 +323,7 @@ asn1_delete_structure2 (asn1_node * structure, unsigned int flags)
p2 = p->right;
if (p != *structure)
{
- p3 = _asn1_get_up (p);
+ p3 = _asn1_find_up (p);
_asn1_set_down (p3, p2);
_asn1_remove_node (p, flags);
p = p3;
@@ -333,7 +333,7 @@ asn1_delete_structure2 (asn1_node * structure, unsigned int flags)
p3 = _asn1_find_left (p);
if (!p3)
{
- p3 = _asn1_get_up (p);
+ p3 = _asn1_find_up (p);
if (p3)
_asn1_set_down (p3, p2);
else
@@ -381,7 +381,7 @@ asn1_delete_element (asn1_node structure, const char *element_name)
p3 = _asn1_find_left (source_node);
if (!p3)
{
- p3 = _asn1_get_up (source_node);
+ p3 = _asn1_find_up (source_node);
if (p3)
_asn1_set_down (p3, p2);
else if (source_node->right)
@@ -443,8 +443,8 @@ _asn1_copy_structure3 (asn1_node source_node)
else
{
move = UP;
- p_s = _asn1_get_up (p_s);
- p_d = _asn1_get_up (p_d);
+ p_s = _asn1_find_up (p_s);
+ p_d = _asn1_find_up (p_d);
}
}
while (p_s != source_node);
@@ -544,7 +544,7 @@ _asn1_type_choice_config (asn1_node node)
move = UP;
}
if (move == UP)
- p = _asn1_get_up (p);
+ p = _asn1_find_up (p);
}
return ASN1_SUCCESS;
@@ -595,7 +595,7 @@ _asn1_expand_identifier (asn1_node * node, asn1_node root)
_asn1_set_right (p3, p2);
else
{
- p3 = _asn1_get_up (p);
+ p3 = _asn1_find_up (p);
if (p3)
_asn1_set_down (p3, p2);
else
@@ -651,7 +651,7 @@ _asn1_expand_identifier (asn1_node * node, asn1_node root)
move = UP;
}
if (move == UP)
- p = _asn1_get_up (p);
+ p = _asn1_find_up (p);
}
return ASN1_SUCCESS;
@@ -1019,7 +1019,7 @@ asn1_print_structure (FILE * out, asn1_node structure, const char *name,
{
while (1)
{
- p = _asn1_get_up (p);
+ p = _asn1_find_up (p);
if (p == root)
{
p = NULL;