Mentions légales du service

Skip to content
Snippets Groups Projects
Commit b03c3220 authored by BOUCHERIE Raphael's avatar BOUCHERIE Raphael
Browse files

memory error, 1 free is missing

parent d90b2031
No related branches found
No related tags found
1 merge request!5Print tree
...@@ -29,13 +29,13 @@ main(int argc, char ** argv) ...@@ -29,13 +29,13 @@ main(int argc, char ** argv)
{ {
libhqr_tree_t qrtree; libhqr_tree_t qrtree;
libhqr_tiledesc_t matrix; libhqr_tiledesc_t matrix;
int maxMN, x1, y1, x2, y2, k, i, j; int maxMN, absciss1, ordinate1, absciss2, ordinate2, k, i, j;
int *tiles; int *tiles;
matrix.nodes = 1; matrix.nodes = 1;
matrix.p = 1; matrix.p = 1;
matrix.mt = 16; matrix.mt = 16;
matrix.nt = 4; 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 ); maxMN = libhqr_imax(matrix.mt, matrix.nt );
tiles = (int*)malloc(maxMN*sizeof(int)); tiles = (int*)malloc(maxMN*sizeof(int));
for ( int i = 0; i < maxMN; i++){ for ( int i = 0; i < maxMN; i++){
...@@ -44,30 +44,31 @@ main(int argc, char ** argv) ...@@ -44,30 +44,31 @@ main(int argc, char ** argv)
FILE *tree = fopen("tree.svg","w+"); FILE *tree = fopen("tree.svg","w+");
libhqr_writeheader(tree); libhqr_writeheader(tree);
for (k = 0; k < 3; k++){ for (k = 0; k < 3; k++){
/* Drawing the horizontal lines */
libhqr_treewalk(&qrtree, k, tiles, tree); libhqr_treewalk(&qrtree, k, tiles, tree);
/* Drawing the vertical lines */ /* Drawing the vertical lines */
for (i = k; i < maxMN; i++){ for (i = k; i < maxMN; i++){
if (i > 0){ if (i > 0){
x1 = x2 = 100 + 100 * tiles[i]; absciss1 = absciss2 = 100 + 100 * tiles[i];
y1 = 100 + 100 * i; ordinate1 = 100 + 100 * i;
y2 = 100 + 100 * (qrtree.currpiv(&qrtree, k, i)); ordinate2 = 100 + 100 * (qrtree.currpiv(&qrtree, k, i));
libhqr_drawline(x1, y1, x2, y2, k, tree); libhqr_drawline(absciss1, ordinate1, absciss2, ordinate2, k, tree);
} }
} }
/* Drawing the rectangles */ /* Drawing the rectangles */
for (i = k + 1; i < maxMN; i++){ for (i = k + 1; i < maxMN; i++){
x1 = 75 + 100 * tiles[i]; absciss1 = 75 + 100 * tiles[i];
y1 = 75 + 100 * i; ordinate1 = 75 + 100 * i;
libhqr_drawTS(x1, y1, WIDTH, HEIGHT, k, tree); libhqr_drawTS(absciss1, ordinate1, WIDTH, HEIGHT, k, tree);
j = qrtree.currpiv(&qrtree, k, i); j = qrtree.currpiv(&qrtree, k, i);
x1 = 75 + 100 * tiles[i]; absciss1 = 75 + 100 * tiles[i];
y1 = 75 + 100 * j; ordinate1 = 75 + 100 * j;
libhqr_drawTT(x1, y1, WIDTH, HEIGHT, k, tree); libhqr_drawTT(absciss1, ordinate1, WIDTH, HEIGHT, k, tree);
} }
} }
libhqr_writeend(tree); libhqr_writeend(tree);
free(tree); libhqr_hqr_finalize( &qrtree );
free(tiles);
return 1; return 1;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment