]> granicus.if.org Git - handbrake/commitdiff
hb_dict: minor improvements.
authorRodeo <tdskywalker@gmail.com>
Thu, 29 Mar 2012 13:25:24 +0000 (13:25 +0000)
committerRodeo <tdskywalker@gmail.com>
Thu, 29 Mar 2012 13:25:24 +0000 (13:25 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4553 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/hb_dict.c

index 5d54d8b4e7c512b380ac99dc18068dac78948585..11206920c444cab52f2e42f9abfb2674b4bae8e2 100644 (file)
@@ -41,16 +41,13 @@ void hb_dict_free( hb_dict_t ** dict_ptr )
                 if( dict->objects[i].key )
                 {
                     free( dict->objects[i].key );
-                    dict->objects[i].key = NULL;
                 }
                 if( dict->objects[i].value )
                 {
                     free( dict->objects[i].value );
-                    dict->objects[i].value = NULL;
                 }
             }
             free( dict->objects );
-            dict->objects = NULL;
         }
         free( *dict_ptr );
         *dict_ptr = NULL;
@@ -129,10 +126,9 @@ hb_dict_entry_t * hb_dict_next( hb_dict_t * dict, hb_dict_entry_t * previous )
         return NULL;
     if( !previous )
         return &dict->objects[0];
-    int i;
-    for( i = 0; i+1 < dict->count; i++ )
-        if( &dict->objects[i] == previous )
-            return &dict->objects[i+1];
+    unsigned int prev_index = previous - dict->objects;
+    if( prev_index + 1 < dict->count )
+            return &dict->objects[prev_index+1];
     return NULL;
 }