* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include <glib.h>
#include <stdlib.h>
+#ifdef G_OS_UNIX
#include <unistd.h>
+#endif
#define N_THREADS 8
#define N_ALLOCS 50000
int n_freed;
} tdata[N_THREADS];
-void*
+static void *
thread_func (void *arg)
{
struct ThreadData *td = arg;
/* g_print ("Thread %d starting\n", td->thread_id); */
for (i = 0; i < N_ALLOCS; i++)
{
+ int bytes;
+ char *mem;
+ int f;
+ int t;
+
if (rand() % (N_ALLOCS / 20) == 0)
g_print ("%c", 'a' - 1 + td->thread_id);
/* allocate block of random size and randomly fill */
- int bytes = rand() % MAX_BLOCK_SIZE + 1;
- char *mem = g_slice_alloc (bytes);
- int f;
+ bytes = rand() % MAX_BLOCK_SIZE + 1;
+ mem = g_slice_alloc (bytes);
+
for (f = 0; f < bytes; f++)
mem[f] = rand();
/* associate block with random thread */
- int t = rand() % N_THREADS;
+ t = rand() % N_THREADS;
g_mutex_lock (&tdata[t].to_free_mutex);
tdata[t].to_free[tdata[t].n_to_free] = mem;
tdata[t].bytes_to_free[tdata[t].n_to_free] = bytes;
}
int
-main()
+main (void)
{
int t;