Hi Huw,
@@ -131,6 +143,73 @@ static void pulse_broadcast(void) pthread_cond_broadcast(&pulse_cond); }
+static unsigned int handle_alloc(struct pulse_stream *stream) +{
- unsigned int index, count;
- struct stream_entry *new_handles;
- pthread_mutex_lock(&handle_lock);
- index = next_free;
- if(index != ~0u) next_free = handles[index].next_free;
- else if(next_unused < num_handles) index = next_unused++;
- else{
count = max(num_handles * 2, 256);
new_handles = realloc(handles, count);
realloc() size is missing multiplication by sizeof(*handles).
Other than that, the patch looks fine to me. One thing I'd mention for consideration: while proper handle table is the right thing for true kernel interface in general, I'm not sure if we need it in such cases. We could just make the handle 64-bit and use Unix pointer as a value of the handle. It would simplify things, but I can see how such "leak" of Unix pointers may be considered less elegant, so it's fine with me both ways.
Thanks,
Jacek