Skip to content

Commit

Permalink
initDSProfile: correct std::vector usage (#4124)
Browse files Browse the repository at this point in the history
Co-authored-by: Roman Savchenko <[email protected]>
  • Loading branch information
stima and ayx-rsavchenko authored Sep 13, 2023
1 parent 566f97a commit 39222a0
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/opencl/openclwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ static ds_status initDSProfile(ds_profile **p, const char *version) {
clGetPlatformIDs(0, nullptr, &numPlatforms);

if (numPlatforms > 0) {
platforms.reserve(numPlatforms);
clGetPlatformIDs(numPlatforms, &platforms[0], nullptr);
platforms.resize(numPlatforms);
clGetPlatformIDs(numPlatforms, platforms.data(), nullptr);
}

numDevices = 0;
Expand All @@ -186,12 +186,11 @@ static ds_status initDSProfile(ds_profile **p, const char *version) {
}

if (numDevices > 0) {
devices.reserve(numDevices);
devices.resize(numDevices);
}

profile->numDevices = numDevices + 1; // +1 to numDevices to include the native CPU
profile->devices.reserve(profile->numDevices);
memset(&profile->devices[0], 0, profile->numDevices * sizeof(ds_device));
profile->devices.resize(profile->numDevices);

next = 0;
for (i = 0; i < numPlatforms; i++) {
Expand Down

0 comments on commit 39222a0

Please sign in to comment.