Commits

Anonymous committed d07c665

Got rid of memory leaks in test_rwlock.c.

  • Participants
  • Parent commits 7dad705

Comments (0)

Files changed (1)

File pthreads/test_rwlock.c

 
     sprintf(id, "Reader %i", context->index);
 
+    free(void_context);
+
     pthread_mutex_lock(&num_active_mutex);
     num_active_threads++;
     pthread_mutex_unlock(&num_active_mutex);
 
     sprintf(id, "Writer %i", context->index);
 
+    free(void_context);
+
     pthread_mutex_lock(&num_active_mutex);
     num_active_threads++;
     pthread_mutex_unlock(&num_active_mutex);
 
     pthread_rwlock_fcfs_destroy(mylock);
 
+    for(a=0;a<NUM_READERS;a++)
+    {
+        pthread_join(readers[a], NULL);
+    }
+    for(a=0;a<NUM_WRITERS;a++)
+    {
+        pthread_join(writers[a], NULL);
+    }
+    
+
+    free(readers);
+    free(writers);
+
     return 0;
 }