Use std::vector for format lists in images suite (#1105)

* Use std::vector for format lists in images suite

Avoids memory deallocation issues and generally simplifies the code.

* Fixup formatting with git-clang-format
This commit is contained in:
James Price
2021-01-14 08:27:59 -05:00
committed by GitHub
parent 0b6fbd15d1
commit 03a0989998
28 changed files with 280 additions and 289 deletions

View File

@@ -42,24 +42,14 @@ int test_image_type( cl_device_id device, cl_context context, cl_command_queue q
int ret = 0;
// Grab the list of supported image formats for integer reads
cl_image_format *formatList;
bool *filterFlags;
unsigned int numFormats;
std::vector<cl_image_format> formatList;
if (get_format_list(context, imageType, formatList, flags)) return -1;
if( get_format_list( context, imageType, formatList, numFormats, flags ) )
return -1;
filterFlags = new bool[ numFormats ];
if( filterFlags == NULL )
{
log_error( "ERROR: Out of memory allocating filter flags list!\n" );
return -1;
}
memset( filterFlags, 0, sizeof( bool ) * numFormats );
filter_formats( formatList, filterFlags, numFormats, 0 );
std::vector<bool> filterFlags(formatList.size(), false);
filter_formats(formatList, filterFlags, nullptr);
// Run the format list
for( unsigned int i = 0; i < numFormats; i++ )
for (unsigned int i = 0; i < formatList.size(); i++)
{
int test_return = 0;
if( filterFlags[i] )
@@ -106,9 +96,6 @@ int test_image_type( cl_device_id device, cl_context context, cl_command_queue q
ret += test_return;
}
delete filterFlags;
delete formatList;
return ret;
}