|
-
June 20th, 2008, 01:52 AM
#1
Managing dynamic array in multi-threaded C program
I am making a multi-threaded C program which involves the sharing of a global dynamic integer array between two threads. One thread will keep adding elements to it & the other will independently scan the array & free the scanned elements. I will use realloc to increment the array & use a local int pointer in the other thread to keep track of the elements scanned. However, my problem is how to free the elements after they have been scanned by my 2nd thread. I tried by having a pointer point to each element of the global array in a for loop & then using the free function, but it only cleared the 1st element. Can somebody please suggest a way out.
On a side note, is this the right way to handle this problem?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|