@@ -1389,7 +1389,6 @@ static int cuda_property(gpucontext *c, gpudata *buf, gpukernel *k, int prop_id,
13891389 }
13901390
13911391 switch (prop_id ) {
1392- char * s ;
13931392 CUdevice id ;
13941393 int i ;
13951394 size_t sz ;
@@ -1401,21 +1400,9 @@ static int cuda_property(gpucontext *c, gpudata *buf, gpukernel *k, int prop_id,
14011400 cuda_exit (ctx );
14021401 return GA_IMPL_ERROR ;
14031402 }
1404- /* 256 is what the CUDA API uses so it's good enough for me */
1405- s = malloc (256 );
1406- if (s == NULL ) {
1407- cuda_exit (ctx );
1408- return GA_MEMORY_ERROR ;
1409- }
1410- ctx -> err = cuDeviceGetName (s , 256 , id );
1411- if (ctx -> err != CUDA_SUCCESS ) {
1412- free (s );
1413- cuda_exit (ctx );
1414- return GA_IMPL_ERROR ;
1415- }
1416- * ((char * * )res ) = s ;
1403+ ctx -> err = cuDeviceGetName ((char * )res , 256 , id );
14171404 cuda_exit (ctx );
1418- return GA_NO_ERROR ;
1405+ return ( ctx -> err != CUDA_SUCCESS ) ? GA_IMPL_ERROR : GA_NO_ERROR ;
14191406
14201407 case GA_CTX_PROP_PCIBUSID :
14211408 cuda_enter (ctx );
@@ -1424,20 +1411,9 @@ static int cuda_property(gpucontext *c, gpudata *buf, gpukernel *k, int prop_id,
14241411 cuda_exit (ctx );
14251412 return GA_IMPL_ERROR ;
14261413 }
1427- s = malloc (13 );
1428- if (s == NULL ) {
1429- cuda_exit (ctx );
1430- return GA_MEMORY_ERROR ;
1431- }
1432- ctx -> err = cuDeviceGetPCIBusId (s , 13 , id );
1433- if (ctx -> err != CUDA_SUCCESS ) {
1434- free (s );
1435- cuda_exit (ctx );
1436- return GA_IMPL_ERROR ;
1437- }
1438- * ((char * * )res ) = s ;
1414+ ctx -> err = cuDeviceGetPCIBusId ((char * )res , 13 , id );
14391415 cuda_exit (ctx );
1440- return GA_NO_ERROR ;
1416+ return ( ctx -> err != CUDA_SUCCESS ) ? GA_IMPL_ERROR : GA_NO_ERROR ;
14411417
14421418 case GA_CTX_PROP_LARGEST_MEMBLOCK :
14431419 * ((size_t * )res ) = largest_size (ctx );
0 commit comments