From b03c322046c5fd5d43567655fee3e94bf5e885d6 Mon Sep 17 00:00:00 2001 From: Raphael Boucherie <raphael.boucherie@inria.fr> Date: Thu, 13 Apr 2017 14:34:20 +0200 Subject: [PATCH] memory error, 1 free is missing --- testings/testing_treedraw.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/testings/testing_treedraw.c b/testings/testing_treedraw.c index d4d8bb4..fea3ee8 100644 --- a/testings/testing_treedraw.c +++ b/testings/testing_treedraw.c @@ -29,13 +29,13 @@ main(int argc, char ** argv) { libhqr_tree_t qrtree; libhqr_tiledesc_t matrix; - int maxMN, x1, y1, x2, y2, k, i, j; + int maxMN, absciss1, ordinate1, absciss2, ordinate2, k, i, j; int *tiles; matrix.nodes = 1; matrix.p = 1; matrix.mt = 16; matrix.nt = 4; - libhqr_hqr_init( &qrtree, LIBHQR_QR, &matrix, LIBHQR_FLAT_TREE, LIBHQR_FLAT_TREE, 1, 2, 0, 0); + libhqr_hqr_init( &qrtree, LIBHQR_QR, &matrix, LIBHQR_BINARY_TREE, LIBHQR_FLAT_TREE, 1, 2, 0, 0); maxMN = libhqr_imax(matrix.mt, matrix.nt ); tiles = (int*)malloc(maxMN*sizeof(int)); for ( int i = 0; i < maxMN; i++){ @@ -44,30 +44,31 @@ main(int argc, char ** argv) FILE *tree = fopen("tree.svg","w+"); libhqr_writeheader(tree); for (k = 0; k < 3; k++){ + /* Drawing the horizontal lines */ libhqr_treewalk(&qrtree, k, tiles, tree); - /* Drawing the vertical lines */ for (i = k; i < maxMN; i++){ if (i > 0){ - x1 = x2 = 100 + 100 * tiles[i]; - y1 = 100 + 100 * i; - y2 = 100 + 100 * (qrtree.currpiv(&qrtree, k, i)); - libhqr_drawline(x1, y1, x2, y2, k, tree); + absciss1 = absciss2 = 100 + 100 * tiles[i]; + ordinate1 = 100 + 100 * i; + ordinate2 = 100 + 100 * (qrtree.currpiv(&qrtree, k, i)); + libhqr_drawline(absciss1, ordinate1, absciss2, ordinate2, k, tree); } } /* Drawing the rectangles */ for (i = k + 1; i < maxMN; i++){ - x1 = 75 + 100 * tiles[i]; - y1 = 75 + 100 * i; - libhqr_drawTS(x1, y1, WIDTH, HEIGHT, k, tree); + absciss1 = 75 + 100 * tiles[i]; + ordinate1 = 75 + 100 * i; + libhqr_drawTS(absciss1, ordinate1, WIDTH, HEIGHT, k, tree); j = qrtree.currpiv(&qrtree, k, i); - x1 = 75 + 100 * tiles[i]; - y1 = 75 + 100 * j; - libhqr_drawTT(x1, y1, WIDTH, HEIGHT, k, tree); + absciss1 = 75 + 100 * tiles[i]; + ordinate1 = 75 + 100 * j; + libhqr_drawTT(absciss1, ordinate1, WIDTH, HEIGHT, k, tree); } } libhqr_writeend(tree); - free(tree); + libhqr_hqr_finalize( &qrtree ); + free(tiles); return 1; } -- GitLab