Pithikos/C-Thread-Pool

thpool_init illogical

mu578 opened this issue · 2 comments

mu578 commented
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.

Why no one cares and solve these issues

@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