mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-05-18 19:51:57 +02:00
s/<!>/<!-- -->/g throughout the documentation to bring the produced
* glib/tmpl/error_reporting.sgml: * glib/tmpl/threads.sgml: * glib/tmpl/arrays_pointer.sgml: * glib/tmpl/arrays_byte.sgml: * glib/tmpl/memory_chunks.sgml: s/<!>/<!-- -->/g throughout the documentation to bring the produced Docbook closer to XML.
This commit is contained in:
parent
3e22c9e449
commit
5cbcd52547
@ -1,3 +1,12 @@
|
|||||||
|
2002-04-18 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/tmpl/error_reporting.sgml:
|
||||||
|
* glib/tmpl/threads.sgml:
|
||||||
|
* glib/tmpl/arrays_pointer.sgml:
|
||||||
|
* glib/tmpl/arrays_byte.sgml:
|
||||||
|
* glib/tmpl/memory_chunks.sgml: s/<!>/<!-- -->/g throughout the
|
||||||
|
documentation to bring the produced Docbook closer to XML.
|
||||||
|
|
||||||
2002-03-25 Sven Neumann <sven@gimp.org>
|
2002-03-25 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* glib/tmpl/scanner.sgml: Fixed documentation about unused struct
|
* glib/tmpl/scanner.sgml: Fixed documentation about unused struct
|
||||||
|
@ -29,7 +29,7 @@ To free a #GByteArray, use g_byte_array_free().
|
|||||||
GByteArray *gbarray;
|
GByteArray *gbarray;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
gbarray = g_byte_array_new (<!>);
|
gbarray = g_byte_array_new (<!-- -->);
|
||||||
for (i = 0; i < 10000; i++)
|
for (i = 0; i < 10000; i++)
|
||||||
g_byte_array_append (gbarray, (guint8*) "abcd", 4);
|
g_byte_array_append (gbarray, (guint8*) "abcd", 4);
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ To free a pointer array, use g_ptr_array_free().
|
|||||||
GPtrArray *gparray;
|
GPtrArray *gparray;
|
||||||
gchar *string1 = "one", *string2 = "two", *string3 = "three";
|
gchar *string1 = "one", *string2 = "two", *string3 = "three";
|
||||||
|
|
||||||
gparray = g_ptr_array_new (<!>);
|
gparray = g_ptr_array_new (<!-- -->);
|
||||||
g_ptr_array_add (gparray, (gpointer) string1);
|
g_ptr_array_add (gparray, (gpointer) string1);
|
||||||
g_ptr_array_add (gparray, (gpointer) string2);
|
g_ptr_array_add (gparray, (gpointer) string2);
|
||||||
g_ptr_array_add (gparray, (gpointer) string3);
|
g_ptr_array_add (gparray, (gpointer) string3);
|
||||||
|
@ -167,7 +167,7 @@ my_function_that_can_fail (GError **err)
|
|||||||
if (tmp_error != NULL)
|
if (tmp_error != NULL)
|
||||||
{
|
{
|
||||||
/* store tmp_error in err, if err != NULL,
|
/* store tmp_error in err, if err != NULL,
|
||||||
* otherwise call g_error_free(<!>) on tmp_error
|
* otherwise call g_error_free(<!-- -->) on tmp_error
|
||||||
*/
|
*/
|
||||||
g_propagate_error (err, tmp_error);
|
g_propagate_error (err, tmp_error);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -95,11 +95,11 @@ To help debug memory chunks, use g_mem_chunk_info() and g_mem_chunk_print().
|
|||||||
GRealArray *array;
|
GRealArray *array;
|
||||||
|
|
||||||
/* Create a GMemChunk to hold GRealArray structures, using the
|
/* Create a GMemChunk to hold GRealArray structures, using the
|
||||||
g_mem_chunk_create(<!>) convenience macro. We want 1024 atoms in each
|
g_mem_chunk_create(<!-- -->) convenience macro. We want 1024 atoms in each
|
||||||
memory block, and we want to be able to free individual atoms. */
|
memory block, and we want to be able to free individual atoms. */
|
||||||
array_mem_chunk = g_mem_chunk_create (GRealArray, 1024, G_ALLOC_AND_FREE);
|
array_mem_chunk = g_mem_chunk_create (GRealArray, 1024, G_ALLOC_AND_FREE);
|
||||||
|
|
||||||
/* Allocate one atom, using the g_chunk_new(<!>) convenience macro. */
|
/* Allocate one atom, using the g_chunk_new(<!-- -->) convenience macro. */
|
||||||
array = g_chunk_new (GRealArray, array_mem_chunk);
|
array = g_chunk_new (GRealArray, array_mem_chunk);
|
||||||
|
|
||||||
/* We can now use array just like a normal pointer to a structure. */
|
/* We can now use array just like a normal pointer to a structure. */
|
||||||
|
@ -172,7 +172,7 @@ system is initialized, you can do that too:
|
|||||||
<para>
|
<para>
|
||||||
<informalexample>
|
<informalexample>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
if (!g_thread_supported (<!>)) g_thread_init (NULL);
|
if (!g_thread_supported (<!-- -->)) g_thread_init (NULL);
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</informalexample>
|
</informalexample>
|
||||||
</para>
|
</para>
|
||||||
@ -458,7 +458,7 @@ access. Take for example the following function:
|
|||||||
<example>
|
<example>
|
||||||
<title>A function which will not work in a threaded environment</title>
|
<title>A function which will not work in a threaded environment</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
int give_me_next_number (<!>)
|
int give_me_next_number (<!-- -->)
|
||||||
{
|
{
|
||||||
static int current_number = 0;
|
static int current_number = 0;
|
||||||
|
|
||||||
@ -481,7 +481,7 @@ access. A first naive implementation would be:
|
|||||||
<example>
|
<example>
|
||||||
<title>The wrong way to write a thread-safe function</title>
|
<title>The wrong way to write a thread-safe function</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
int give_me_next_number (<!>)
|
int give_me_next_number (<!-- -->)
|
||||||
{
|
{
|
||||||
static int current_number = 0;
|
static int current_number = 0;
|
||||||
int ret_val;
|
int ret_val;
|
||||||
@ -510,15 +510,15 @@ not use such constructs in your own programs. One working solution is:
|
|||||||
<programlisting>
|
<programlisting>
|
||||||
static GMutex *give_me_next_number_mutex = NULL;
|
static GMutex *give_me_next_number_mutex = NULL;
|
||||||
|
|
||||||
/* this function must be called before any call to give_me_next_number (<!>)
|
/* this function must be called before any call to give_me_next_number (<!-- -->)
|
||||||
it must be called exactly once. */
|
it must be called exactly once. */
|
||||||
void init_give_me_next_number (<!>)
|
void init_give_me_next_number (<!-- -->)
|
||||||
{
|
{
|
||||||
g_assert (give_me_next_number_mutex == NULL);
|
g_assert (give_me_next_number_mutex == NULL);
|
||||||
give_me_next_number_mutex = g_mutex_new (<!>);
|
give_me_next_number_mutex = g_mutex_new (<!-- -->);
|
||||||
}
|
}
|
||||||
|
|
||||||
int give_me_next_number (<!>)
|
int give_me_next_number (<!-- -->)
|
||||||
{
|
{
|
||||||
static int current_number = 0;
|
static int current_number = 0;
|
||||||
int ret_val;
|
int ret_val;
|
||||||
@ -656,7 +656,7 @@ safer version of our <function>give_me_next_number()</function> example:
|
|||||||
<example>
|
<example>
|
||||||
<title>Using <structname>GStaticMutex</structname> to simplify thread-safe programming</title>
|
<title>Using <structname>GStaticMutex</structname> to simplify thread-safe programming</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
int give_me_next_number (<!>)
|
int give_me_next_number (<!-- -->)
|
||||||
{
|
{
|
||||||
static int current_number = 0;
|
static int current_number = 0;
|
||||||
int ret_val;
|
int ret_val;
|
||||||
@ -805,7 +805,7 @@ variable you intent to protect with the lock. Look at our
|
|||||||
<programlisting>
|
<programlisting>
|
||||||
G_LOCK_DEFINE (current_number);
|
G_LOCK_DEFINE (current_number);
|
||||||
|
|
||||||
int give_me_next_number (<!>)
|
int give_me_next_number (<!-- -->)
|
||||||
{
|
{
|
||||||
static int current_number = 0;
|
static int current_number = 0;
|
||||||
int ret_val;
|
int ret_val;
|
||||||
@ -1033,7 +1033,7 @@ example:
|
|||||||
g_static_rw_lock_writer_lock (&rwlock);
|
g_static_rw_lock_writer_lock (&rwlock);
|
||||||
|
|
||||||
if (!array)
|
if (!array)
|
||||||
array = g_ptr_array_new ();
|
array = g_ptr_array_new (<!-- -->);
|
||||||
|
|
||||||
if (index >= array->len)
|
if (index >= array->len)
|
||||||
g_ptr_array_set_size (array, index+1);
|
g_ptr_array_set_size (array, index+1);
|
||||||
@ -1245,7 +1245,7 @@ void push_data (gpointer data)
|
|||||||
g_mutex_unlock (data_mutex);
|
g_mutex_unlock (data_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
gpointer pop_data ()
|
gpointer pop_data (<!-- -->)
|
||||||
{
|
{
|
||||||
gpointer data;
|
gpointer data;
|
||||||
|
|
||||||
@ -1402,7 +1402,7 @@ done as follows:
|
|||||||
GPrivate* current_number_key = NULL; /* Must be initialized somewhere */
|
GPrivate* current_number_key = NULL; /* Must be initialized somewhere */
|
||||||
/* with g_private_new (g_free); */
|
/* with g_private_new (g_free); */
|
||||||
|
|
||||||
int give_me_next_number ()
|
int give_me_next_number (<!-- -->)
|
||||||
{
|
{
|
||||||
int *current_number = g_private_get (current_number_key);
|
int *current_number = g_private_get (current_number_key);
|
||||||
|
|
||||||
@ -1519,7 +1519,7 @@ the difference between #GMutex and #GStaticMutex. Now look at our
|
|||||||
<example>
|
<example>
|
||||||
<title>Using GStaticPrivate for per-thread data</title>
|
<title>Using GStaticPrivate for per-thread data</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
int give_me_next_number ()
|
int give_me_next_number (<!-- -->)
|
||||||
{
|
{
|
||||||
static GStaticPrivate current_number_key = G_STATIC_PRIVATE_INIT;
|
static GStaticPrivate current_number_key = G_STATIC_PRIVATE_INIT;
|
||||||
int *current_number = g_static_private_get (&current_number_key);
|
int *current_number = g_static_private_get (&current_number_key);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user