1
1

Remove some memory leaks in the test program. (Thanks valgrind).

This commit was SVN r1096.
Этот коммит содержится в:
George Bosilca 2004-04-27 18:12:33 +00:00
родитель 258677c453
Коммит a82a47a33e

Просмотреть файл

@ -1,6 +1,7 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
#include "datatype.h"
#include "datatype_internal.h"
#include <time.h>
#include <stdlib.h>
#include <sys/time.h>
@ -116,7 +117,7 @@ int mpich_typeub2( void )
}
else
printf("Example 3.26 type1 correct\n" );
OBJ_RELEASE( dt2 ); assert( dt2 == NULL );
lam_ddt_create_contiguous(2,dt1,&dt2);
lam_ddt_type_lb(dt2, &lb); lam_ddt_type_ub(dt2, &ub);
lam_ddt_type_extent(dt2,&ex2); lam_ddt_type_size(dt2,&sz2);
@ -147,12 +148,9 @@ int mpich_typeub2( void )
else
printf( "type3 correct\n" );
OBJ_RELEASE( dt1 );
assert( dt1 == NULL );
OBJ_RELEASE( dt2 );
assert( dt2 == NULL );
OBJ_RELEASE( dt3 );
assert( dt3 == NULL );
OBJ_RELEASE( dt1 ); assert( dt1 == NULL );
OBJ_RELEASE( dt2 ); assert( dt2 == NULL );
OBJ_RELEASE( dt3 ); assert( dt3 == NULL );
return err;
}
@ -178,7 +176,6 @@ int mpich_typeub3( void )
lam_ddt_commit(&dt1);
/* This type is the same as in typeub2, and is tested there */
types[0]=dt1; types[1]=dt1;
blocklen[0]=1; blocklen[1]=1;
disp[0]=-4; disp[1]=7;
@ -232,7 +229,6 @@ int mpich_typeub3( void )
lam_ddt_type_lb( dt5, &lb ); lam_ddt_type_ub( dt5, &ub );
lam_ddt_type_extent( dt5, &ex ); lam_ddt_type_size( dt5, &sz );
if (lb != -3 || ub != 132 || ex != 135) {
printf("vector lb %d ub %d extent %d size %d\n", (int)-3, (int)132, (int)135, sz);
printf("vector lb %d ub %d extent %d size %d\n", (int)lb, (int)ub, (int)ex, sz);
@ -270,11 +266,13 @@ int init_random_upper_matrix( size_t N, double* mat )
int i, j;
srand( time(NULL) );
for( i = 0; i < N; i++ )
for( i = 0; i < N; i++ ) {
mat += i;
for( j = i; j < N; j++ ) {
*mat = (double)random();
mat++;
}
}
return 0;
}
@ -361,7 +359,7 @@ int test_upper( size_t length )
init_random_upper_matrix( length, mat1 );
mat2 = calloc( length * length, sizeof(double) );
total_length = length * (length + 1) / 2 * sizeof(double);
total_length = length * (length + 1) * ( sizeof(double) / 2);
inbuf = (double*)malloc( total_length );
ptr = (char*)inbuf;
/* copy upper matrix in the array simulating the input buffer */
@ -375,8 +373,8 @@ int test_upper( size_t length )
lam_convertor_init_for_recv( pConv, 0, pdt, 1, mat2, 0 );
/* test the automatic destruction pf the data */
OBJ_RELEASE( pdt ); assert( pdt == NULL );
OBJ_RELEASE( pdt1 ); assert( pdt1 == NULL );
lam_ddt_destroy( &pdt ); assert( pdt == NULL );
lam_ddt_destroy( &pdt1 ); assert( pdt1 == NULL );
GET_TIME( start );
split_chunk = (length + 1) * sizeof(double);
@ -388,6 +386,7 @@ int test_upper( size_t length )
lam_convertor_unpack( pConv, &a, 1 );
ptr += split_chunk;
i -= split_chunk;
if( mat2[0] != inbuf[0] ) assert(0);
}
GET_TIME( end );
total_time = ELAPSED_TIME( start, end );
@ -398,6 +397,7 @@ int test_upper( size_t length )
rc = check_diag_matrix( length, mat1, mat2 );
free( mat1 );
free( mat2 );
OBJ_RELEASE( pConv );
return rc;
}
@ -520,8 +520,9 @@ dt_desc_t* create_strange_dt( void )
OBJ_RELEASE( pdt2 ); assert( pdt2 == NULL );
lam_ddt_dump( pdt );
{
dt_type_desc_t pElemDesc;
dt_type_desc_t pElemDesc = { 0, 0, NULL };
lam_ddt_optimize_short( pdt, 1, &pElemDesc );
if( pElemDesc.desc != NULL ) free( pElemDesc.desc );
}
return pdt;
}
@ -541,6 +542,8 @@ int local_copy_ddt_count( dt_desc_t* pdt, int count )
free( pdst );
free( psrc );
OBJ_RELEASE( pdt ); assert( pdt == NULL );
return 0;
}
int main( int argc, char* argv[] )
@ -551,17 +554,11 @@ int main( int argc, char* argv[] )
lam_ddt_init();
pdt = create_strange_dt();
return 0;
/*
local_copy_ddt_count(pdt, 10);
OBJ_RELEASE( pdt ); assert( pdt == NULL );
*/
pdt = upper_matrix(100);
local_copy_ddt_count(pdt, 1);
OBJ_RELEASE( pdt ); assert( pdt == NULL );
return 0;
return 0;
mpich_typeub();
mpich_typeub2();
@ -607,5 +604,9 @@ int main( int argc, char* argv[] )
OBJ_RELEASE( pdt1 ); assert( pdt1 == NULL );
OBJ_RELEASE( pdt2 ); assert( pdt2 == NULL );
OBJ_RELEASE( pdt3 ); assert( pdt3 == NULL );
/* clean-ups all data allocations */
lam_ddt_finalize();
return 0;
}