Fri, 07 Mar 2003 11:35:36 +0000
more work on pdf_add_tree_element().
pdf_name_tree.c | file | annotate | diff | revisions |
1.1 --- a/pdf_name_tree.c Fri Mar 07 11:28:45 2003 +0000 1.2 +++ b/pdf_name_tree.c Fri Mar 07 11:35:36 2003 +0000 1.3 @@ -4,7 +4,7 @@ 1.4 * will be compressed using ITU-T T.6 (G4) fax encoding. 1.5 * 1.6 * PDF routines 1.7 - * $Id: pdf_name_tree.c,v 1.2 2003/03/07 03:28:45 eric Exp $ 1.8 + * $Id: pdf_name_tree.c,v 1.3 2003/03/07 03:35:36 eric Exp $ 1.9 * Copyright 2003 Eric Smith <eric@brouhaha.com> 1.10 * 1.11 * This program is free software; you can redistribute it and/or modify 1.12 @@ -112,6 +112,8 @@ 1.13 new_node = pdf_calloc (1, sizeof (struct pdf_name_tree_node)); 1.14 new_node->parent = node->parent; 1.15 new_node->leaf = node->leaf; 1.16 + 1.17 + /* $$$ insert new node in parent's kids array */ 1.18 } 1.19 1.20 1.21 @@ -140,7 +142,26 @@ 1.22 return; 1.23 } 1.24 1.25 - /* $$$ figure out in which slot to insert it */ 1.26 + /* figure out in which slot to insert it */ 1.27 + for (i = 0; i < node->count; i++) 1.28 + if (pdf_compare_obj (key, node->keys [i] < 0)) 1.29 + break; 1.30 + 1.31 + /* move other entries right one position */ 1.32 + if (i != node->count) 1.33 + { 1.34 + memmove (& node->keys [i+1], 1.35 + & node->keys [i], 1.36 + (node->count - i) * sizeof (struct pdf_obj *)); 1.37 + memmove (& node->values [i+1], 1.38 + & node->values [i], 1.39 + (node->count - i) * sizeof (struct pdf_obj *)); 1.40 + } 1.41 + 1.42 + node->keys [i] = key; 1.43 + node->values [i] = val; 1.44 + 1.45 + node->count++; 1.46 1.47 /* update limits, recursing upwards if necessary */ 1.48 if (i == 0) 1.49 @@ -161,7 +182,6 @@ 1.50 node->max_key = key; 1.51 } 1.52 } 1.53 - 1.54 } 1.55 1.56