M
mjoachimiak
Hi,
I used smth like this (forgive me typos):
//////////////////////////
mystrucure *dynamic_element = NULL
void some_function()
{
if (dynamic_element == NULL)
dynamic_element = malloc(sizeofm(mystructure));
if (dynamic_element != NULL) do_smth(dynamic_element);
}
main()
{
call some_function() many times;
if (dynamic_element != NULL)
free(dynamic_element);
}
/////////////////////////////
there is a doc about GMutex
http://library.gnome.org/devel/glib/unstable/glib-Threads.html#GMutex
that says that this line
if (!mutex) mutex = g_mutex_new ();
can cause race condition.
what about my previous memory allocation ?
Can it cause race condition also?
BR
I used smth like this (forgive me typos):
//////////////////////////
mystrucure *dynamic_element = NULL
void some_function()
{
if (dynamic_element == NULL)
dynamic_element = malloc(sizeofm(mystructure));
if (dynamic_element != NULL) do_smth(dynamic_element);
}
main()
{
call some_function() many times;
if (dynamic_element != NULL)
free(dynamic_element);
}
/////////////////////////////
there is a doc about GMutex
http://library.gnome.org/devel/glib/unstable/glib-Threads.html#GMutex
that says that this line
if (!mutex) mutex = g_mutex_new ();
can cause race condition.
what about my previous memory allocation ?
Can it cause race condition also?
BR