]> git.llucax.com Git - z.facultad/75.06/emufs.git/blobdiff - emufs/indice_bplus.c
Borro parte redundante.
[z.facultad/75.06/emufs.git] / emufs / indice_bplus.c
index 1882cd6f26a89a2898c7be760f7e68cf5f492435..b147284a6db3f0b3d91840c2206f034bda5a1c9a 100644 (file)
@@ -372,9 +372,10 @@ int b_plus_buscar_prepost(INDICE *idx, CLAVE key, int num_node, INDEX_DAT *prepo
                                                        b_plus_destruir_nodo(nodo);
                                                        nodo = b_plus_leer_nodo(idx,num_node);
                                                        prepostkey->clave = nodo->claves[0];
                                                        b_plus_destruir_nodo(nodo);
                                                        nodo = b_plus_leer_nodo(idx,num_node);
                                                        prepostkey->clave = nodo->claves[0];
-                                                       prepostkey->num_bloque = nodo->hijos[0];                                                        
+                                                       prepostkey->num_bloque = nodo->hijos[0];
+                                                       exitcode = 1;                                                   
                                                } 
                                                } 
-                                               else exitcode = 1; /* No hay mas */
+                                               else exitcode = -1; /* No hay mas */
                                        }
                                        else {                                                                                          
                                                prepostkey->clave = nodo->claves[i+1];                                          
                                        }
                                        else {                                                                                          
                                                prepostkey->clave = nodo->claves[i+1];                                          
@@ -705,7 +706,10 @@ CLAVE emufs_b_plus_obtener_menor_clave(INDICE *idx) {
                        b_plus_destruir_nodo(node);                     
                        node = b_plus_leer_nodo(idx,num_child);
                }
                        b_plus_destruir_nodo(node);                     
                        node = b_plus_leer_nodo(idx,num_child);
                }
-               else break;             
+               else {
+                       b_plus_destruir_nodo(node);
+                       return key;             
+               }
        }
        
        /* Ahora estoy en la primer hoja del arbol, devuelvo la primer clave */
        }
        
        /* Ahora estoy en la primer hoja del arbol, devuelvo la primer clave */
@@ -724,6 +728,7 @@ CLAVE emufs_b_plus_obtener_mayor_clave(INDICE *idx) {
        node = b_plus_leer_nodo(idx,0);
        if (node == NULL) {
                key.i_clave = -1;
        node = b_plus_leer_nodo(idx,0);
        if (node == NULL) {
                key.i_clave = -1;
+               b_plus_destruir_nodo(node);
                return key;
        }
        
                return key;
        }
        
@@ -736,12 +741,16 @@ CLAVE emufs_b_plus_obtener_mayor_clave(INDICE *idx) {
                        node = b_plus_leer_nodo(idx,num_child);
                        cant_claves = node->cant_claves;
                }
                        node = b_plus_leer_nodo(idx,num_child);
                        cant_claves = node->cant_claves;
                }
-               else return key;                
+               else {
+                       b_plus_destruir_nodo(node);
+                       return key;             
+               }
        }
        
        /* Ahora estoy en la ultima hoja del arbol, devuelvo la ultima clave */         
        bucket = idx->padre->obtener_claves_raw(idx->padre,node->hijos[cant_claves-1]);
        key = bucket->claves[bucket->cant_keys-1];
        }
        
        /* Ahora estoy en la ultima hoja del arbol, devuelvo la ultima clave */         
        bucket = idx->padre->obtener_claves_raw(idx->padre,node->hijos[cant_claves-1]);
        key = bucket->claves[bucket->cant_keys-1];
+       free(bucket->claves);
        free (bucket);  
        b_plus_destruir_nodo(node);
        
        free (bucket);  
        b_plus_destruir_nodo(node);