memory bug fixes

This commit is contained in:
2025-06-14 10:41:22 -04:00
parent 92169317f2
commit 566c04f6e8
26 changed files with 25 additions and 17 deletions

View File

@ -12,8 +12,8 @@ namespace imglib4
template<typename callable, typename ... argst> int threaded_execute(callable &&fptr, int64_t psize, argst&&... args)
{
int ret = amsimage_success;
int nthreads;
int I;
int nthreads = 1;
int I = 0;
std::vector<std::thread*> threads;
if(psize<amsimage_threadpsz)
@ -28,6 +28,14 @@ template<typename callable, typename ... argst> int threaded_execute(callable &&
nthreads = (nthreads<=0) ? 1 : nthreads;
nthreads = (nthreads>amsimage_maxthreads) ? amsimage_maxthreads : nthreads;
threads.resize(nthreads);
if(threads.size()!=nthreads)
{
//fallback to single threaded execution
nthreads = 1;
I = 0;
fptr(I,nthreads,std::forward<argst>(args)...);
return amsimage_success;
}
for(I=0;I<nthreads;I++) threads[I] = NULL;
for(I=0;I<nthreads;I++)
{