Pithikos / C-Thread-Pool

A minimal but powerful thread pool in ANSI C
MIT License
2.06k stars 603 forks source link

thpool_init illogical #58

Closed mu578 closed 9 months ago

mu578 commented 7 years ago
struct thpool_* thpool_init(int num_threads){

    threads_on_hold   = 0;
    threads_keepalive = 1;

-   if (num_threads < 0){
-       num_threads = 0;
-   }
+   if (num_threads < 1){
+       num_threads = 1;
+      // OR assert(...)
+   }

// jump to -> 
thpool_p->threads = (struct thread**)malloc(num_threads * sizeof(struct thread *));
// -> 0 x N = 0; -> malloc(0);
// anyhow what would be the point of having a thread pool without any thread ? 8-)

thusss.

atefrice commented 2 years ago

Why no one cares and solve these issues

Pithikos commented 9 months ago

@atefrice well it would be merged if the code posted was an actual PR

Regardless, this seems like a usage issue so closing for now