Ajout d'une note pour gérer la fin inattendue du fichier

This commit is contained in:
Mattéo Delabre 2016-11-20 01:48:32 +01:00
parent b9b9e35115
commit ef8d547f6b
1 changed files with 6 additions and 2 deletions

View File

@ -2,6 +2,7 @@
#include "huftree.h"
#include "buffer.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
@ -152,11 +153,14 @@ void writeTree(HufTree tree, WriteBuffer* buffer) {
HufTree readTree(ReadBuffer* buffer) {
HufTree tree = malloc(sizeof(*tree));
if (getBuffer(buffer) == 1) {
char bit = getBuffer(buffer);
// FIXME: gérer la fin inattendue du fichier
if (bit == 1) {
// Sommet avec enfants
tree->child_l = readTree(buffer);
tree->child_r = readTree(buffer);
} else {
} else if (bit == 0) {
// Feuille de l'arbre
int name = 0;