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