Commit Graph

4094 Commits

Author SHA1 Message Date
John Ralls
47475dbe6a [Bug 529806] Cannot build in 64-bit Mac OS X due to libiconv 2012-02-24 17:04:52 -08:00
Filippo Della Betta
462f7f5a4d Added better support of G_STRFUNC for Visual Studio platform
https://bugzilla.gnome.org/show_bug.cgi?id=670128
2012-02-24 16:21:45 -05:00
Richard Hughes
eece6cb9c3 Fix up 'Since:' for g_mapped_file_new_from_fd()
It was introduced in 2.31.0, not 2.30.x
2012-02-23 10:34:46 +00:00
Dan Winship
98a70df486 gthread-posix: fix order of arguments in g_thread_abort() message 2012-02-22 11:38:43 -05:00
Dan Winship
88182d375e gasyncqueue: fix a 32bit overflow in g_async_queue_timed_pop
also, add a test for g_async_queue_timed_pop() and
g_async_queue_timeout_pop() to tests/asyncqueue.c

https://bugzilla.gnome.org/show_bug.cgi?id=669670
2012-02-22 11:36:08 -05:00
David King
2ca6c475ea docs: Fix g_async_queue_timeout_pop_unlocked typo 2012-02-21 01:10:55 +01:00
David King
912ac79041 docs: Add some missing G_TOKEN_* descriptions 2012-02-21 01:10:54 +01:00
David King
708d4178ce docs: Fix g_key_file_load_from_file error parameter 2012-02-21 01:10:54 +01:00
Matthias Clasen
dbc01d3090 Don't rely on /bin/sh
Another Fedora UsrMove victim !
2012-02-21 00:26:19 +01:00
Christian Persch
eafb108caf gbytes: Add G_BEGIN/END_DECL guards
Bug #670138.
2012-02-15 17:46:31 +01:00
Christian Persch
26f238e85d Plug a mem leak in g_environ_unsetenv
And clarify the memory allocation requirement of the string arrays passed to
g_environ_{,un}setenv().

==9458== 10 bytes in 1 blocks are definitely lost in loss record 16 of 39
==9458==    at 0x402AD89: malloc (vg_replace_malloc.c:236)
==9458==    by 0x4221A1F: vasprintf (vasprintf.c:78)
==9458==    by 0x40C6065: g_vasprintf (gprintf.c:314)
==9458==    by 0x409D894: g_strdup_vprintf (gstrfuncs.c:509)
==9458==    by 0x409D8C9: g_strdup_printf (gstrfuncs.c:535)
==9458==    by 0x40672E9: g_environ_setenv (genviron.c:156)
==9458==    by 0x80490E7: test_environ_array (environment.c:78)
==9458==    by 0x40A3DB5: test_case_run (gtestutils.c:1662)
==9458==    by 0x40A40B2: g_test_run_suite_internal (gtestutils.c:1715)
==9458==    by 0x40A417C: g_test_run_suite_internal (gtestutils.c:1726)
==9458==    by 0x40A42F9: g_test_run_suite (gtestutils.c:1771)
==9458==    by 0x40A3441: g_test_run (gtestutils.c:1319)
==9458==    by 0x80493F1: main (environment.c:108)

Bug #669412.
2012-02-15 17:45:44 +01:00
Dan Winship
ca05902a58 Add G_GNUC_BEGIN/END_IGNORE_DEPRECATIONS
Add new macros to disable -Wdeprecated-declarations around a piece of
code, using the C99 (and GNU89) _Pragma() operator. Replace the
existing use of #pragma for this in gio, and suppress the warnings in
gvaluearray.c as well.

https://bugzilla.gnome.org/show_bug.cgi?id=669671
2012-02-15 09:54:38 -05:00
Giovanni Campagna
d240b88315 GKeyFile: fix annotation of g_key_file_load_from_data
(array) without (element-type) means "array of the same type as
the C type", so gchar* with (array) is interpreted as an array of
strings. Since GKeyFiles must be UTF-8 encoded anyway, just
annotate it as a string.

https://bugzilla.gnome.org/show_bug.cgi?id=658484
2012-02-14 19:05:08 +01:00
Dan Winship
dd553a2ba3 gasyncqueue: deprecate GTimeVal-based methods, add relative-delay ones
https://bugzilla.gnome.org/show_bug.cgi?id=669670
2012-02-13 09:09:08 -05:00
Matthias Clasen
8cb48f644d Fix a parameter name mismatch
gtk-doc gets unhappy if parameters aren't named the same in
headers, sources and doc comments.
2012-02-10 21:09:39 -05:00
Christophe Fergeau
6d3b31a533 Fix g_hash_table_foreach crash with NULL hash table
When G_DISABLE_ASSERT is not defined, g_hash_table_foreach and
g_hash_table_find dereferences the hash table argument before
checking if it's NULL. This causes a crash when one of this function
is mistakenly called with a NULL argument instead of returning
with a warning through g_return_if_fail.
2012-02-10 10:03:38 +01:00
Dan Winship
daf78764e5 gthread-win32: update for g_get_monotonic_time() changes
g_cond_wait_until() was calling GetSystemTimeAsFileTime() to get the
current time, which is no longer what g_get_monotonic_time() returns.

https://bugzilla.gnome.org/show_bug.cgi?id=669329
2012-02-09 06:48:12 -05:00
Ravi Sankar Guntur
90dbaca924 glib/tests: mainloop - fix a mem leak.
https://bugzilla.gnome.org/show_bug.cgi?id=669372

Signed-off-by: Ravi Sankar Guntur <ravi.g@samsung.com>
2012-02-08 09:36:12 -05:00
Ravi Sankar Guntur
bd79c00537 glib/tests: fix memory leak
https://bugzilla.gnome.org/show_bug.cgi?id=669372

Signed-off-by: Ravi Sankar Guntur <ravi.g@samsung.com>
2012-02-08 09:23:54 -05:00
Dan Winship
a8f516f61e glib/tests/option-context: remove unused tests
These tests were written, but then never used since it was decided to
add g_warnings() to goption.c in the cases they were supposed to be
testing. So anyway, just remove them.
2012-02-08 08:46:03 -05:00
Giovanni Campagna
1faed130dc gtimezone: consider a leading : in TZ environment variable
When set to represent a zoneinfo file, TZ may start with :, therefore
glib needs to check it and ignore the first char when building the
resulting filename, or it won't be found.
Also, the path could be absolute, in which case it is wrong to
append /usr/share/timezone

https://bugzilla.gnome.org/show_bug.cgi?id=664237
2012-02-06 17:26:30 +01:00
Christian Persch
7e9aed94de Revert "Plug a mem leak in g_environ_unsetenv"
This reverts commit 2f4b46e378, which was
pushed accidentally.
2012-02-05 20:00:16 +01:00
Christian Persch
2f4b46e378 Plug a mem leak in g_environ_unsetenv
==9458== 10 bytes in 1 blocks are definitely lost in loss record 16 of 39
==9458==    at 0x402AD89: malloc (vg_replace_malloc.c:236)
==9458==    by 0x4221A1F: vasprintf (vasprintf.c:78)
==9458==    by 0x40C6065: g_vasprintf (gprintf.c:314)
==9458==    by 0x409D894: g_strdup_vprintf (gstrfuncs.c:509)
==9458==    by 0x409D8C9: g_strdup_printf (gstrfuncs.c:535)
==9458==    by 0x40672E9: g_environ_setenv (genviron.c:156)
==9458==    by 0x80490E7: test_environ_array (environment.c:78)
==9458==    by 0x40A3DB5: test_case_run (gtestutils.c:1662)
==9458==    by 0x40A40B2: g_test_run_suite_internal (gtestutils.c:1715)
==9458==    by 0x40A417C: g_test_run_suite_internal (gtestutils.c:1726)
==9458==    by 0x40A42F9: g_test_run_suite (gtestutils.c:1771)
==9458==    by 0x40A3441: g_test_run (gtestutils.c:1319)
==9458==    by 0x80493F1: main (environment.c:108)

Bug #669412.
2012-02-05 19:57:09 +01:00
Ravi Sankar Guntur
59a0134de8 fix memory leak in g_bookmark_file_parse()
https://bugzilla.gnome.org/show_bug.cgi?id=669334

Signed-off-by: Ravi Sankar Guntur <ravi.g@samsung.com>
2012-02-04 10:01:19 -05:00
Matthias Clasen
3758b41e08 Add a test to show that GMarkup properly handles > in content 2012-01-31 22:02:22 -05:00
Matthias Clasen
a6bafde5f2 Dist gconstructor.h 2012-01-30 17:54:33 -05:00
Alexander Larsson
968f4e8d79 Move constructor macros to an internal header and into generated code
With this we're not longer exporting the constructor headers, which means
we're not tying ourselves to a macro that might need special tweaking on
a compiler-by-compiler basis.
2012-01-30 16:59:27 +01:00
Antoine Jacoutot
e43a98c000 goption: implement platform_get_argv0() for OpenBSD
https://bugzilla.gnome.org/show_bug.cgi?id=669024
2012-01-30 16:17:06 +01:00
Ravi Sankar Guntur
7486cd946a comments/docs: Fix couple of typos
https://bugzilla.gnome.org/show_bug.cgi?id=668857
2012-01-28 07:52:56 +01:00
Ryan Lortie
9bfde4a53f GKeyFile: allow loading from empty strings
GKeyFile supports empty files and also supports loading from the string
"", but will fail with a critical if you try:

  - explicit length == 0
  - data == NULL

length == 0 should always be valid, and data == NULL should be valid in
the case that length == 0, so add some testcases for those and fix the
code up to allow them.

https://bugzilla.gnome.org/show_bug.cgi?id=668756
2012-01-26 14:40:34 -05:00
Dan Winship
1542e898f9 gmain: fix a bunch of comment typos in g_get_monotonic_time()
And remove a comment about Windows in the fallback implementation that
no longer applies, since there's now a separate Windows-specific
implementation.
2012-01-26 09:54:50 -05:00
Andoni Morales Alastruey
59881a65b2 keyfile tests: Fix windows build using portable g_setenv 2012-01-26 14:44:50 +01:00
Matthias Clasen
ef159af00f Use G_SOURCE_CONTINUE/REMOVE internally
Now that we have these macros, we should use them.
This commit covers everything in glib/.
2012-01-25 16:15:18 -05:00
Ryan Lortie
12060df9f1 GHash: add note about randomness in hashing
To clarify our statements about being robust against outside attackers
degrading the performance of your hashtable.
2012-01-25 10:09:09 -05:00
Matthias Clasen
e94a5f4f83 GKeyFile: make list separators effective again
We must preserve the list_separator across clear;init
sequences.
2012-01-25 07:32:39 -05:00
Matthias Clasen
aea9951ef0 Fix the new test 2012-01-25 07:32:20 -05:00
Matthias Clasen
e50d7e065c Add a test for g_key_file_set_list_separator
A recent 'harmless' fix broke it...
2012-01-25 07:26:58 -05:00
Guillaume Desmottes
ca949756de GArray: initialize the clear_func pointer
https://bugzilla.gnome.org/show_bug.cgi?id=668650
2012-01-25 12:04:12 +01:00
Ravi Sankar Guntur
e9725d1656 Macro to insert a new GNode "after" the given sibling.
https://bugzilla.gnome.org/show_bug.cgi?id=626258

Signed-off-by: Ravi Sankar Guntur <ravi.g@samsung.com>
2012-01-24 23:41:23 -05:00
Emmanuele Bassi
c602a5f887 array: Add a clear function
Like GPtrArray has a "free function" that can be used to free memory
associated to each pointer in the array, GArray would benefit from
having a "clear function" that can be used to clear the content of
each element of the array when it's removed, or when the entire array
is freed.

https://bugzilla.gnome.org/show_bug.cgi?id=667243
2012-01-24 23:25:38 -05:00
Matthias Clasen
030b3f25e3 GHashTable: Add a note about hash collisions 2012-01-24 21:11:13 -05:00
Ryan Lortie
26d4feae0c keyfile tests: Add testcase for bug #634232
Add a testcase based on one by Alfredo Dal'Ava Júnior (the original
reporter of the bug).

https://bugzilla.gnome.org/show_bug.cgi?id=634232
2012-01-24 17:17:08 -05:00
Ryan Lortie
fe10b2c966 GKeyFile: remove approximate_size optimisation
This is micro-optimisation of the worst kind and it's causing obscure
bugs in edge cases.  Better just remove this entirely.

https://bugzilla.gnome.org/show_bug.cgi?id=634232
2012-01-24 17:16:48 -05:00
Dan Winship
b6a8dec558 g_date_time_format: fix output in non-UTF-8 locales
In non-UTF-8 locales, the translations and nl_langinfo() return values
must be converted to UTF-8 before being returned to the caller.
Likewise, when making a recursive call to expand a format like '%x',
the format string must first be converted to UTF-8.

https://bugzilla.gnome.org/show_bug.cgi?id=668250
2012-01-20 19:50:48 -05:00
Dan Winship
3691194b35 g_base64_encode_step: clarify break_lines behavior a bit
break_lines uses LFs, not CRLFs like you might expect (since it's
designed for email-related use), but we can't change that now since
the caller has to allocate the output buffer and so the
number-of-bytes-output is part of the ABI. So, just document that.

https://bugzilla.gnome.org/show_bug.cgi?id=668158
2012-01-18 09:02:21 -05:00
Kjartan Maraas
3fe710c0b5 Fix broken build with -Wundefined 2012-01-17 17:10:19 +01:00
Patrick Welche
decac50c15 Protect call to pthread_condattr_setclock with define.
While here update pthread_attr_setstacksize test to use AC_LINK_IFELSE
and avoid an unused variable in glib/tests/thread.c.

https://bugzilla.gnome.org/show_bug.cgi?id=667790
2012-01-15 23:41:27 -05:00
Simon McVittie
6d9f874330 g_error_new_valist, g_error_copy: warn if domain is 0 or message is NULL
Neither of those usages is valid, but there's a lot of use of 0 as a
domain "in the wild", so we can't g_return_if_fail yet.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=660371
2012-01-15 23:21:03 -05:00
Matthias Clasen
186c15fc87 GError: small documentation addition
Document that out variables are not guaranteed to be set to
defined values if an error is thrown. Inspired by bug 658315
2012-01-15 23:18:09 -05:00
Matthias Clasen
5377c0de01 Beef up Libs.private in glib-2.0.pc
This should help getting static builds working on mingw.
Based on a patch by Volker Grabsch, bug 619126.

At the same time, drop the unnecessary GLIB_RT_LIBS variable;
we are already adding -lrt to G_THREAD_LIBS.
2012-01-15 22:15:10 -05:00
Dan Winship
673396fb65 gmain: fix adding a child source to an already-attached source
Adding a child source to an already-attached parent source would
crash, because we were passing the parent's context when setting the
child's priority.
2012-01-15 09:39:14 -05:00
Benjamin Otte
a6e149e41f array: return_if_fail() if element size is 0
This is particular useful for:
  g_array_new (sizeof (MyStruct), FALSE, FALSE);
because the correct incantation is
  g_array_new (FALSE, FALSE, sizeof (MyStruct));
and these warnings will trigger in the first situation.
2012-01-14 01:15:16 +01:00
Alexander Larsson
9ef4554a0b Add macros to handle constructor functions on the compilers that support it
This is only supported on some compilers, so we define G_HAS_CONSTRUCTORS
when it is supported. However, when it is supported we guarantee that
both constructors and destructors work, in executables as well as shared
libraries (including runtime unloading of shared libraries).

Usage is a bit unorthodox, as some compilers need to use #pragma to
implement constructors, and #pragma can't be used in macros.

The canonical way to use this:

  #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
  #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor)
  #endif
  G_DEFINE_CONSTRUCTOR(my_constructor)

  static void my_constructor (void)
  {
    ...

  #ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
  #pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(my_destructor)
  #endif
  G_DEFINE_DESTRUCTOR(my_destructor)

  static void my_destructor (void)
  {
    ...
2012-01-13 16:02:47 +01:00
Philip Withnall
e98f17e5cf Bug 666700 — Add some missing (allow-none) annotations
Add some missing (allow-none) annotations to GContentType, GIcon and
GHashTable methods.

Closes: bgo#666700
2012-01-11 20:48:29 +00:00
Ravi Sankar Guntur
0ed2cdb0d9 Use g_queue_free_full() convenience function.
https://bugzilla.gnome.org/show_bug.cgi?id=667331

Signed-off-by: Ravi Sankar Guntur <ravi.g@samsung.com>
2012-01-09 19:27:39 -05:00
Matthias Clasen
ddf9633d95 fix a compiler warning 2012-01-09 15:27:07 -05:00
Matthias Clasen
39dc681fc7 Realign the hash set example with added api
Change the name of set_insert to set_add, to better match the
newly added g_hash_table_add.
2012-01-09 15:23:25 -05:00
Dan Vrátil
7678b10703 Fix GHashTable GDB pretty printing (bug #667420) 2012-01-09 09:29:20 +01:00
Jasper St. Pierre
d141940bc6 gthread-posix: Remove misleading documentation comments
g_thread_init() has done nothing since 2.32, so while the function
still can be used if "g_thread_init() has not yet been called",
it won't do nothing in that case, it will just perform normally.
2012-01-06 14:41:08 -05:00
Jasper St. Pierre
021e116f05 gbacktrace: g_get_prgname () isn't called for a NULL argument
https://bugzilla.gnome.org/show_bug.cgi?id=658871
2012-01-06 14:41:08 -05:00
Ryan Lortie
21d2c49f82 minor fixup to last commit 2012-01-06 10:25:03 -05:00
Ryan Lortie
752f0cac15 GHashTable: new 'add' and 'contains' APIs
These are both convenience APIs that make it slightly nicer to use
GHashTable as a set (which is something we document as officially
supported).
2012-01-06 10:18:41 -05:00
Simon McVittie
2fe964eeb1 Mention g_test_undefined() when documenting assert_failed, assert_stderr
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666116
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Colin Walters <walters@verbum.org>
2012-01-05 15:47:50 +00:00
Javier Jardón
e3d53d5529 glib/*: Use g_slist_free_full() convenience function 2012-01-05 04:57:48 +01:00
Matthias Clasen
1b919d2e56 Clarify g_utf8_strlen docs a bit 2012-01-04 00:10:11 -05:00
Paolo Borelli
d64b4c4887 Add a testcase for an old regex bug.
Add a testcase for bug #455640, which was fixed in PCRE versions newer
than 7.2.
2012-01-03 21:17:48 +01:00
Javier Jardón
2ae83e116b glib/*: Use g_list_free_full() 2012-01-03 16:53:47 +01:00
Stef Walter
411259ddd3 gvariant: Never break out of g_variant_iter_loop
* Document how to break out of g_variant_iter_loop style loops.

https://bugzilla.gnome.org/show_bug.cgi?id=664069
2012-01-02 18:34:08 +01:00
Simon McVittie
1425aa664d GBitLock: turn assumptions of g_futex_int_address into a static assertion
We'll probably never encounter a platform where these fail, but that's
what static assertions are for...

https://bugzilla.gnome.org/show_bug.cgi?id=548954
2012-01-02 12:23:01 -05:00
Ryan Lortie
fc731de929 gthread.h: avoid anonymous union
This is a GNU extension.

https://bugzilla.gnome.org/show_bug.cgi?id=666978
2012-01-02 11:39:01 -05:00
Matthias Clasen
8558ae9ad4 Correct some Since tags
As pointed out in bug 666951, g_mkdtemp and g_mkdtemp_full
were only added in 2.30.
2011-12-29 11:57:42 -05:00
Ravi Sankar Guntur
8ca2647c74 Fix to handle '\v' (vertical tab) by g_strescape() and g_strcompress().
fix enables g_strescape() and g_strcompress() to handle '\v' along with other
special characters - '\b', '\f', '\n', '\r', '\t', '\'.

https://bugzilla.gnome.org/show_bug.cgi?id=664830

Signed-off-by: Ravi Sankar Guntur <ravi.g@samsung.com>
2011-12-27 21:49:19 -05:00
Simon McVittie
993de34a77 Add undefined/no-undefined mode options to GTester
https://bugzilla.gnome.org/show_bug.cgi?id=666116
2011-12-27 17:51:11 -05:00
Simon McVittie
fa4792c35e various tests: do not provoke SIGTRAP with -m no-undefined
Some of the GLib tests deliberately provoke warnings (or even fatal
errors) in a forked child. Normally, this is fine, but under valgrind
it's somewhat undesirable. We do want to follow fork(), so we can check
for leaks in child processes that exit gracefully; but we don't want to
be told about "leaks" in processes that are crashing, because there'd
be no point in cleaning those up anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=666116
2011-12-27 17:51:09 -05:00
Simon McVittie
5cb29d7909 Clarify documentation of fast/slow/thorough and quiet/verbose tests
It turns out that there is no middle setting between fast and
slow/thorough, but there *is* a middle setting between quiet and verbose.

https://bugzilla.gnome.org/show_bug.cgi?id=666116
2011-12-27 17:51:04 -05:00
Matthias Clasen
8cea99741b Don't put documentation in glibconfig.h 2011-12-27 16:22:13 -05:00
Matthias Clasen
4576a459fc Remove obsolescent AC_HEADER_STDC macro
We only used the resulting define in one place, and really,
these headers just have to be around or its not worth trying.
2011-12-27 15:55:04 -05:00
Thomas Hindoe Paaboel Andersen
49a4de3ea4 docs: g_atexit: do not point in a direction for where to find details
https://bugzilla.gnome.org/show_bug.cgi?id=666804
2011-12-27 10:18:41 -05:00
Benjamin Otte
c4fc258424 docs: Clarify non-NUL requirement in g_utf8_validate()
UTF8 validation is not about your character on a dating site, so don't
talk about meeting.

https://bugzilla.gnome.org/show_bug.cgi?id=666803
2011-12-24 14:26:24 +01:00
rodrigorivascosta
1b03377442 Bug 666551-Fix a few dangling pointers
When removing an item from the list, check the next one's my_owner,
and fix it accordingly. And take this case into account when last
of the list is deleted.

Also, assign NULL to 'my_owner' in g_thread_xp_WakeConditionVariable.
2011-12-22 10:51:31 +08:00
Chun-wei Fan
76bc1ab280 glib/tests/private.c: Fix compilation on Windows
-process.h must be included for _beginthreadex
-Use a cast to HANDLE on _beginthreadex to silence warnings on different
 types
2011-12-22 10:39:05 +08:00
Ryan Lortie
541693f42d winxp threads: fix some condition variable races
There are some races in the condition variable emulation code for
Windows XP with respect to timeouts while waiting.

First, in the event of a timeout, we never remove the waiter from the
condition variable.  This can cause crashes later.  That problem was
found by Rodrigo Rivas Costa.

Second, if the waiting thread times out and exits just as we were about
to call SetEvent() on its waiter event, we could end up trying to access
the waiter after it was closed/freed.  We need to hold on to the lock a
little bit longer to ensure that that's not possible.

https://bugzilla.gnome.org/show_bug.cgi?id=666551
2011-12-19 17:40:08 -05:00
Ryan Lortie
11015f1652 windows XP threads: fix hilariously obvious race
I tried to do a double-checked lock without the double check.

Rodrigo Rivas Costa caught the problem and suggested the (obviously
correct) fix.

https://bugzilla.gnome.org/show_bug.cgi?id=666296
2011-12-16 10:54:42 -05:00
Ravi Sankar Guntur
1d4009e6f7 Added API g_queue_free_full().
g_queue_free_full(), to free a Queue including its dynamically-allocated elements.
On similar lines to List and Slist.

void  g_queue_free_full  (GQueue  *queue,  GDestroyNotify    free_func);

Test case covering g_queue_free_full() is added.
Added export symbol to glib.symbols.

Closes Bug: https://bugzilla.gnome.org/show_bug.cgi?id=657433

Signed-off-by: Ravi Sankar Guntur <ravi.g@samsung.com>
2011-12-16 09:51:16 -05:00
Stef Walter
14fb10d14b GBytes: add a size argument to g_bytes_get_data
* An out size argument so that this is more easily bindable
   by gobject-introspection.

https://bugzilla.gnome.org/show_bug.cgi?id=665879
2011-12-15 07:22:37 +01:00
Simon McVittie
e129deb017 g_array_free, g_ptr_array_free: decrement refcount if not the last ref
foo_free is conceptually "worth" one unref; not decrementing the
refcount here means the GArray or GPtrArray wrapper (but not its
contents) would leak in the following call sequence:

    p = g_ptr_array_new ();
    g_ptr_array_ref (p);
    g_ptr_array_free (p, TRUE);
    g_ptr_array_unref (p);

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666113
Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-12-14 18:10:31 +00:00
Simon McVittie
df9d9cc72f GArray, GPtrArray: factor out the actual freeing
Depending how the array is freed, we may want to free the underlying
array (the "segment"), the struct wrapper or both.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666113
Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-12-14 18:10:25 +00:00
Simon McVittie
6457677b7d g_key_file_get_string_list: don't leak the pieces on error
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666113
Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-12-14 18:09:48 +00:00
Ryan Lortie
a2e9318d4a two test fixes for ARM
First, some ARM systems are not fast enough to meet the 30 second
deadline in gwakeuptest.c, so increase that to 60.

Second, we have some signed/unsigned woes in the gparam transform tests.
2011-12-14 09:33:30 -05:00
Simon McVittie
f6b2847e57 hash test: avoid leaking various keys and values
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666115
Reviewed-by: Matthias Clasen <mclasen@redhat.com>
2011-12-14 12:40:57 +00:00
Simon McVittie
5dca72fe67 GOptionContext test: free all arguments, not just the remaining ones
On success, g_option_context_parse alters argv by removing options that
it understood, so g_strfreev is insufficient. Instead, take a shallow
copy and free all of the arguments in that, then free the array argv
but not its contents.

Also, improve the checks in error cases, by checking that argv has
not been altered in this way.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666115
Reviewed-by: Matthias Clasen <mclasen@redhat.com>
2011-12-14 12:40:39 +00:00
Simon McVittie
29f2ced8eb various GLib tests: plug memory leaks
These don't really matter, since it's test code, but they do obscure
real leaks in the library.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666115
Acked-by: Matthias Clasen <mclasen@redhat.com>
2011-12-14 12:40:16 +00:00
Simon McVittie
93f8f8158f g_variant_byteswap: don't leak serialised.data
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666113
Reviewed-by: Matthias Clasen <mclasen@redhat.com>
2011-12-14 12:26:17 +00:00
Simon McVittie
c49a4dba82 g_data_set_internal: avoid use-after-free if datalist is in dataset
Removing the last thing in a dataset frees the dataset, and if the
datalist was in a dataset, we can't safely unlock it after the dataset
has been freed. Unlock it sooner.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666113
Reviewed-by: Matthias Clasen <mclasen@redhat.com>
2011-12-14 12:26:17 +00:00
Simon McVittie
0bf8378840 g_strcompress: check that source is non-NULL rather than just crashing
Calling this function with a NULL argument is considered to be invalid,
but one of the regression tests does it anyway (to watch it crash), which
seems a good indication that it's expected to be somewhat common.
Let's check it rather than segfaulting.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666113
Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
Reviewed-by: Matthias Clasen <mclasen@redhat.com>
2011-12-14 12:26:17 +00:00
Simon McVittie
90baa7e460 GKeyFile: free group comments when the group is removed
These were leaked. Valgrind was sad.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666113
Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-12-14 12:26:16 +00:00
Simon McVittie
9ddb2f8091 g_hmac_get_string: don't allocate and leak an unused buffer
Also document why we're not actually using the buffer for anything.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666113
Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-12-14 12:26:16 +00:00
Simon McVittie
64ca85ceae g_hmac_copy: initialize the refcount
In practice, the uninitialized refcount will typically mean that the copy is
never freed, and leaks.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666113
Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-12-14 12:26:16 +00:00
Matthias Clasen
edfab83c07 Add an explicit deprecation note to g_thread_init
https://bugzilla.gnome.org/show_bug.cgi?id=666145
2011-12-14 07:16:45 -05:00
Stef Walter
7e92997539 documentation fixes
Fixes for gtk-doc warnings.

http://bugzilla.gnome.org/show_bug.cgi?id=66469

https://bugzilla.gnome.org/show_bug.cgi?id=664699
2011-12-13 23:01:51 -05:00
Matthias Clasen
042954de9f Fix since tag 2011-12-10 21:49:10 -05:00
Ryan Lortie
a8927732c9 GDate: gtk-doc fixup 2011-12-10 14:09:54 -05:00
Philip Withnall
386bb0faad unicode: Fix a few issues with G_UNICHAR_MAX_DECOMPOSITION_LENGTH
Raised by Matthias in bgo#665685 but which I didn't spot until after pushing
commit 3ac7c35656.

Renames G_UNICHAR_MAX_DECOMPOSITION_LEN to G_UNICHAR_MAX_DECOMPOSITION_LENGTH
and fixes a few documentation issues.

See: bgo#665685
2011-12-06 19:41:31 +00:00
Philip Withnall
3ac7c35656 Bug 665685 — Add a #define for the max length of a Unicode decomposition
Add G_UNICHAR_MAX_DECOMPOSITION_LEN for the maximum length of the
decomposition of a single Unicode character.

Closes: bgo#665685
2011-12-06 19:09:01 +00:00
Behdad Esfahbod
10a154446c Minor doc fix. 2011-12-06 13:20:39 -05:00
Behdad Esfahbod
91fb373d55 Minor 2011-12-06 13:19:27 -05:00
Philip Withnall
22da18fa70 GVariant: add preconditions to ref. counting functions
These prevent GVariants from accidentally being brought back to life after
being freed, and should make it easier to track down ref. counting issues.

Closes: bgo#665184
2011-12-02 10:23:14 +00:00
Matthias Clasen
b13e79da62 Don't abort if g_ascii_strtod tests fail
https://bugzilla.gnome.org/show_bug.cgi?id=652560
2011-11-29 22:54:45 -05:00
Geek87
22748dbbc9 Remove two useless lines of code
https://bugzilla.gnome.org/show_bug.cgi?id=648516
2011-11-29 22:16:53 -05:00
Geek87
27e70806c1 Fix a little comment error in the _GTreeNode struct
https://bugzilla.gnome.org/show_bug.cgi?id=648516
2011-11-29 22:16:52 -05:00
Carlos Garcia Campos
4ce5a11daf gtester: Add command line option to skip tests
https://bugzilla.gnome.org/show_bug.cgi?id=664809
2011-11-27 14:33:47 +01:00
Stef Walter
fcc69fd318 GBytes: A new type for an immutable set of bytes.
* Represents an immutable reference counted block of memory.
 * This is basically the internal glib GBuffer structure exposed,
   renamed, and with some additional capabilities.
 * The GBytes name comes from python3's immutable 'bytes' type
 * GBytes can be safely used as keys in hash tables, and have
   functions for doing so: g_bytes_hash, g_bytes_equal
 * GByteArray is a mutable form of GBytes, and vice versa. There
   are functions for converting from one to the other efficiently:
   g_bytes_unref_to_array() and g_byte_array_free_to_bytes()
 * Adds g_byte_array_new_take() to support above functions

https://bugzilla.gnome.org/show_bug.cgi?id=663291
2011-11-24 08:58:38 +01:00
Matthias Clasen
1b01109377 Add some more mainloop tests 2011-11-22 23:57:18 -05:00
Matthias Clasen
d0e2865a2e Remove unnecessary includes
These were meant for some other test that ended up not getting
added. This fixes bug 664559.
2011-11-22 19:31:30 -05:00
Matthias Clasen
6dde6b7f21 Add back required _XOPEN_SOURCE define
This got lost somewhere between 2.30 and now, but it is needed
for isnan(). See bug 664354, reported by Tim Mooney.
2011-11-22 19:12:48 -05:00
Ryan Lortie
0f1fb417bf Missed a couple of @returns 2011-11-21 11:39:52 -05:00
Ryan Lortie
0e0554bd62 GVariant: drop use of @returns 2011-11-21 11:33:21 -05:00
Matthias Clasen
4527e7cbf7 gbitlock: Drop @returns syntax from doc comments 2011-11-21 11:09:42 -05:00
Matthias Clasen
22d3972284 GBuffer: Drop @returns syntax from doc comments 2011-11-21 11:05:43 -05:00
Matthias Clasen
ef4ae742ce Improve test coverage 2011-11-21 01:53:29 -05:00
Matthias Clasen
89ad8bda23 Improve mainloop test coverage slightly 2011-11-21 01:40:51 -05:00
Matthias Clasen
b0fa096870 Improve test coverage 2011-11-21 01:02:50 -05:00
Matthias Clasen
0fd14b1a56 Fix a case conversion bug
For titlecase chars without uppercase variant, we were returning
0, contrary to the docs.
2011-11-21 00:28:41 -05:00
Matthias Clasen
5197870665 Improve test coverage 2011-11-21 00:28:41 -05:00
Matthias Clasen
4cbacb91de Add a test for g_unichar_isdefined 2011-11-21 00:28:41 -05:00
Josselin Mouette
ff2f4a12ee Document that g_list_sort is a stable sort.
This is a guarantee for the future so that applications can rely on it.

https://bugzilla.gnome.org/show_bug.cgi?id=531973
2011-11-20 16:53:36 +01:00
Giovanni Campagna
d2fd6dac4a GMain: allow NULL context to g_source_attach
Documentation says it's fine and means default context, but the annotations
are missing (and thus bindings would complain).

https://bugzilla.gnome.org/show_bug.cgi?id=664302
2011-11-18 15:21:17 +01:00
Jürg Billeter
fcffe6abbb GKeyFile: Accept empty files
It already accepts files consisting solely of whitespace.

https://bugzilla.gnome.org/show_bug.cgi?id=663432
2011-11-17 23:11:41 -05:00
Simon McVittie
a0c755710c Document exactly what g_time_val_to_iso8601() produces
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=537637
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2011-11-17 23:11:01 -05:00
Matthias Clasen
1a08591c3a Deal gracefully with NULL log domains 2011-11-16 21:42:28 -05:00
Alexander Larsson
3a7960f757 win32: Make g_get_monotonic_clock lockless 2011-11-16 09:10:46 +01:00
Alexander Larsson
8d023c2706 win32: Use timeGetTime as monotonic base
This allows apps that need it to increase timer accuracy
using timeBeginPeriod
2011-11-16 09:10:46 +01:00
Alexander Larsson
64dec8ad9f win32: Add a monotonic timer 2011-11-16 09:10:45 +01:00
Sjoerd Simons
469e1a15a0 Fix 1bit mutex test on platforms with 32 bit aligned pointers
The 1 bit mutex tests asserts: ((gsize) ptrs) % 8, ==, 0), which fails
when the platform only aligns porters to 32 bits (e.g. S390 and
powerpc).

I'm not sure why this assertion was placed here, but given
that internally g_pointer_bit_trylock uses g_atomic_int_or internally
change the assertion so it only requires the alignment to be a multiple
of sizeof(int)
2011-11-15 09:27:00 +01:00
Matthias Clasen
65eb65b777 Avoid unused variable warnings in g_ascii_strtod 2011-11-14 23:30:18 -05:00
Matthias Clasen
7c0ee79e34 GThread: handle thread names safely
Avoid a race condition where the string may be freed before
the new thread got around to using it. Also add a test for
thread names.

https://bugzilla.gnome.org/show_bug.cgi?id=663381
2011-11-14 22:18:13 -05:00
Matthias Clasen
3f0d275295 Move remaining docs inline
This introduces a fake source file just for holding
docs that have no good place elsewhere. Not great, but
better than templates.
2011-11-14 21:22:46 -05:00
Matthias Clasen
2195e20dce Move GDate docs inline 2011-11-14 21:22:46 -05:00
Matthias Clasen
18da6e6be9 Move i18n docs inline 2011-11-14 21:22:46 -05:00
Matthias Clasen
c8b0617a2b Move slice and hook docs inline 2011-11-14 21:22:37 -05:00
Dan Winship
29f786851d Fix glib/tests/utils for g_parse_debug_string() changes 2011-11-14 13:55:14 -05:00
Matthias Clasen
06bb6c75a2 More consistent doc formatting
Move some things around, make capitalization of short descriptions
more consistent.
2011-11-12 21:54:42 -05:00
Matthias Clasen
599f254066 Cleanups to debug env var handling 2011-11-12 19:13:44 -05:00
Matthias Clasen
943a18b564 Parse G_DEBUG only once 2011-11-12 18:36:52 -05:00
Matthias Clasen
5d9f05eef1 glib-unix.h: Add G_BEGIN/END_DECLS
The omission was pointed out in bug 663880.
2011-11-12 10:32:35 -05:00
Chun-wei Fan
faebf0f653 gstrfuncs.c: Fix variable declaration
Declare variables at top of block to stop C89 compilers from complaining.
2011-11-12 10:38:31 +08:00
Kristian Rietveld
f218353e04 Need to include xlocale.h on Darwin for strtod_l
This fixes the build of gstrfuncs.c on Darwin.
2011-11-09 08:32:33 +01:00
Benjamin Otte
7d1c7af1a6 docs: Improve g_variant_loop() docs
Typo fix and changing "is not recommended" to the nice version of "don't
do this", aka "causes undefined behavior".
2011-11-07 15:29:51 +01:00
Benjamin Otte
14677e16d8 docs: Tell which function to use to avoid errors. 2011-11-07 15:29:51 +01:00
Alexander Larsson
41b8ce7100 win32: Remove some debug spew on startup
This is not needed anymore and was causing problems for pkg-config.
2011-11-03 17:27:08 +01:00
Matthias Clasen
d2d62ecfcd Make the default log handler more useful
We make the default log handler only print default and informational
messages if the log domain is explicitly requested.

https://bugzilla.gnome.org/show_bug.cgi?id=661926
2011-11-03 01:50:29 -04:00
Matthias Clasen
7456b43c3e Move old deprecated gmain api into deprecated/ 2011-11-03 00:39:31 -04:00
Matthias Clasen
a3c8712c4b Remove single-include guards in deprecated/
Not allowed to include these headers single anymore, either.
2011-11-03 00:31:14 -04:00
Matthias Clasen
03766a1a38 Don't use G_DISABLE_DEPRECATED guards around deprecated functions
I'm leaving the old-style deprecation guards in place around
deprecated macros, enumeration values, etc, for now.
2011-11-03 00:04:15 -04:00
Ryan Lortie
4c038429b1 Revert "gthread: G_STATIC_MUTEX_INIT: Fix this for the non-win32 case."
This reverts commit 52fd106724.
2011-10-26 15:10:33 -04:00
Murray Cumming
52fd106724 gthread: G_STATIC_MUTEX_INIT: Fix this for the non-win32 case.
Also initialize the unused member. This was correct before but
was broken when the ifndef was moved inside the GStaticMutex
struct:
http://git.gnome.org/browse/glib/commit/glib/gthread.h?id=24652730a9faaedb19b9e90024077eb7f75a6907
This avoids a compiler warning.
2011-10-26 12:11:58 +02:00
Will Thompson
5e2a2ef288 g_parse_debug_string: invert flags given besides "all"
Any flags specified as well as "all" are subtracted from the result,
allowing the user to specify FOO_DEBUG="all,bar,baz" to mean "give me
debugging information for everything except bar and baz".

https://bugzilla.gnome.org/show_bug.cgi?id=642452
2011-10-24 20:35:30 -04:00
Matthias Clasen
73e3c98df0 Fix g_hash_table_iter_replace
When reusing an existing key 'internally', we must avoid calling
the key_destroy function on the old key.

https://bugzilla.gnome.org/show_bug.cgi?id=662544
2011-10-24 13:29:17 -04:00
Matthias Clasen
e52437982c Make g_ascii_strtod behave as documented
The docs explicitly state that we reset errno, so lets do that,
even if we just wrap strtod_l. Also move the argument check
out of the ifdef.

https://bugzilla.gnome.org/show_bug.cgi?id=662398
2011-10-21 15:00:14 -04:00
Matthias Clasen
269acbe703 Deprecate g_atexit
This function was just not a good idea to begin with.
Its documentation gives plenty of reason not to use it.
2011-10-19 21:03:43 -04:00
Ryan Lortie
2a98cc635e The usual docs unbreaking... 2011-10-19 15:07:22 -04:00
Ryan Lortie
99f0eaa4c5 Fix bug in g_static_rec_mutex_unlock_full()
pthreads doesn't implement the _lock_full() and _unlock_full() calls on
recursive mutexes so we don't have it on GRecMutex either.  Now that
we're using GRecMutex to implement GStaticRecMutex, we have to fake it
by keeping an internal counter of the number of locks and calling
g_rec_mutex_unlock() the appropriate number of times.

The code to do this looked like:

  depth = mutex->depth;
  while (mutex->depth--)
    g_rec_mutex_unlock (rm);
  return depth;

which unfortunately did one last decrement after mutex->depth was
already zero (leaving it equal to -1).

When locked the next time, the count would then increase from -1 to 0
and then the next _unlock_full() call would not do any calls to
g_rec_mutex_unlock(), leading to a deadlock.

https://bugzilla.gnome.org/show_bug.cgi?id=661914
2011-10-18 23:26:00 -04:00
Ryan Lortie
aba0f0c38b gatomic: introduce G_ATOMIC_LOCK_FREE
We clean up the detection of if we should do 'real' atomic operations or
mutex-emulated ones with the introduction of a new (public) macro:
G_ATOMIC_LOCK_FREE.  If defined, our atomic operations are guaranteed to
be done in hardware.

We need to use __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 to determine if our
compiler supports GCC-style atomic operations from the gatomic.h header
because we might be building a program against GLib using a different
set of compiler options (or a different compiler) than was used to build
GLib itself.

Unfortunately, this macro is not available on clang, so it has currently
regressed to using the mutex emulation.  A bug about that has been
opened here:

  http://llvm.org/bugs/show_bug.cgi?id=11174
2011-10-18 16:45:28 -04:00
Ryan Lortie
c9b6c3c85a gatomic: cast to the correct pointer sign
In the fallback case of the g_atomic_int_ macros we had some (gint*)
casts that should have been (guint*) casts.
2011-10-18 16:45:28 -04:00
Alexander Larsson
cf3f1b026b Actually Don't define GLIB_COMPILATION in libgthread
Last commit was wrong, fixing it up
2011-10-18 14:15:07 +02:00
Alexander Larsson
be770969e9 Don't define GLIB_COMPILATION in libgthread
This was turning all the GLIB_VARs in the glib headers into
dllexports on windows, causing all sort of nastiness. libgthread is
mostly empty now anyway, so we don't need any GLIB_COMPILATION like
flag.
2011-10-18 13:34:06 +02:00
Matthias Clasen
735420e546 Fix an include guard mismatch
Spotted by Colin Walters.
2011-10-17 17:01:36 -04:00
Chun-wei Fan
f3ac581713 Move _glib_get_locale_dir to ggettext.c
-Move _glib_get_locale_dir to ggettext.c, as Matthias suggested
-Made up for the headers that needed to be included in ggettext.c to avoid
 C4013 (implicit declaration of ...) errors/warnings
2011-10-18 01:01:02 +08:00
Chun-wei Fan
b25177fc4f GLib: Add forgotten includes and build fixes
-gcharset.c, genviron.c, gunicollate.c: Some headers were missed in those
 files that triggered C4013 warnings/errors (aka. implicit declaration
 of ... in GCC).  Make up for them here.
-gwin32.h: Only define g_win32_get_package_installation_directory/
 g_win32_get_package_installation_subdirectory as macros
 (alias of g_win32_get_package_installation_directory_utf8/
 g_win32_get_package_installation_subdirectory_utf8) on Win64 (x64) as
 g_win32_get_package_installation_directory/
 g_win32_get_package_installation_subdirectory have seperate existing
 implmentations for Win32-this is a long-standing problem but was covered-
 up by G_DISABLE_DEPRECATED, which we are stopping to use as of 2.31.0.
2011-10-17 23:54:05 +08:00
Ryan Lortie
e5fd0f5df6 Revert "Bug 652827 - glib-2.29.8 no longer builds with mingw.org's toolchain"
This reverts commit 3492122112.
2011-10-17 10:55:02 -04:00
Chun-wei Fan
e192f45a93 glib/tests/thread.c: Add config guards
Not all systems come with unistd.h and sys/time.h, so use config guards
on them so that they are only included when available.
2011-10-17 17:18:20 +08:00
Matthias Clasen
2f71118e78 More include cleanups 2011-10-17 02:14:39 -04:00
Matthias Clasen
0ec3c744c4 include cleanup 2011-10-17 01:59:35 -04:00
Matthias Clasen
d9053e026c Make things compile again 2011-10-17 01:52:10 -04:00
Matthias Clasen
08933846e4 Move gettext variations into their own files 2011-10-17 01:50:00 -04:00
Matthias Clasen
67bf0083db Reshuffle some functions between gutils and gfileutils
Move filename-related functions to gfileutils, and move
size formatting functions to gutils.
2011-10-17 01:30:31 -04:00
Matthias Clasen
23afdb119e include cleanup 2011-10-17 01:30:09 -04:00
Matthias Clasen
f8a7471308 Trivial 2011-10-17 01:11:56 -04:00
Matthias Clasen
fbe24cab21 Reshuffle genviron.c
Split win32 functions off into their own section, instead
of having large and unwieldy ifdef sections inside each function.

Also move the compat versions of env functions over from gutils.c
2011-10-17 00:39:43 -04:00
Ryan Lortie
b0ab7aba6b push G_THREADS_MANDATORY over the cliff
This was used as an optimisation for the macro hackery that used to live
in gthread.h.  If a particular library or program knew that it could
rely on thread support being enabled, it would allow for static
evaluation of conditionals in some of those macros.

Since the macros are dead and thread support is now always-on, we can
get rid of this bit of legacy.
2011-10-16 21:59:55 -04:00
Ryan Lortie
a6d9cf3380 gthread/: fix up declarations
g_thread_init() is now a deprecated API, so drop G_DISABLE_DEPRECATED
from the CFLAGS for gthread/.  Add the missing declaration for
g_thread_init_with_errorcheck_mutexes() back to deprecated/gthread.h.
2011-10-16 21:50:26 -04:00
Ryan Lortie
3eec796b18 Add private prototype for g_thread_init_glib()
This function was never put in a header and was only used internally
from libgthread, but we should keep the symbol around to avoid
triggering any false-positives on ABI checkers.

For -Wmissing-prototypes compatibility with this unusual case, we should
add a private prototype in the .c file just before.
2011-10-16 21:41:15 -04:00
Ryan Lortie
740eacbfca static and #include fixups in glib/ 2011-10-16 21:41:15 -04:00
Ryan Lortie
1b018a8bb2 genviron: #include fixups 2011-10-16 21:41:15 -04:00
Ryan Lortie
3d93c44374 Mark some functions 'static' in glib/tests
This has uncovered two unused testcases in option-context.c.  They are
currently broken and require more investigation (which is probably why
they are unused).
2011-10-16 21:41:15 -04:00
Ryan Lortie
c5aa8390b2 gitignore 2011-10-16 19:11:00 -04:00
Ryan Lortie
a9a1c97904 gthread: move test cases to glib/ 2011-10-16 19:08:59 -04:00
Ryan Lortie
fb4e120d88 tests: merge gthread/ and glib/ atomic tests 2011-10-16 19:04:19 -04:00
Ryan Lortie
f5e8694782 glib/tests/atomic: convert to proper gtester test 2011-10-16 19:01:55 -04:00
Matthias Clasen
6c1d768f7b Also clean up includes 2011-10-16 18:43:22 -04:00
Matthias Clasen
0589f715e5 Move charset and locale name functions to their own files
They did not really belong into either gutils or gutf8.
2011-10-16 18:40:58 -04:00
Matthias Clasen
86cc4b246d Add deprecation annotations to mem chunk apis 2011-10-16 17:37:29 -04:00
Matthias Clasen
e7b4319d61 Move version APIs out of gutils
Just another cleanup.
2011-10-16 17:01:26 -04:00
Matthias Clasen
45f221c32f Move GTrashStack out of gutils.[hc]
Reducing the mess in gutils, and moving docs inline
at the same time. Double win.
2011-10-16 16:52:24 -04:00
Matthias Clasen
6ab1c77270 Pass correct data to fatal log handlers
This was pointed out by John Ralls in bug 653052.
He also provided the test case.
2011-10-16 16:24:20 -04:00
Martin Pitt
1435db48ba Clarify g_spawn_*() behaviour without full path
Document the previously uncovered case of calling g_spawn_async_with_pipes()
without a full path but no G_SPAWN_SEARCH_PATH. This runs programs from the
current directory, which might be unexpected and even dangerous in some corner
cases.

https://bugzilla.gnome.org/show_bug.cgi?id=656621
2011-10-16 16:09:33 -04:00
Matthias Clasen
cbb0b2a0ed Add g_get_codeset test 2011-10-15 23:58:30 -04:00
Matthias Clasen
1493285f1d Add GAsyncQueue unit test 2011-10-15 23:58:18 -04:00
Matthias Clasen
d0bb1e0b0a Move g_get_codeset next to g_get_charset
g_get_codeset is a close relatove to g_get_charset, and up to now
it lived a shadowy existence without any header presence.
2011-10-15 23:27:28 -04:00
Matthias Clasen
976b0b72a4 Include genviron.h where necessary 2011-10-15 20:06:32 -04:00
Matthias Clasen
327e72f9fb And fix the syntax, too 2011-10-15 19:39:14 -04:00
Matthias Clasen
7df9637f0f Forgotten file 2011-10-15 19:38:10 -04:00
Matthias Clasen
d4dfca21bb Drop unused copy of _g_getenv_nomalloc 2011-10-15 18:23:07 -04:00
Giovanni Campagna
94accc2d78 GKeyFile: improve introspection annotations
Ensure that all methods that take or return arrays are annotated
(including length). Mark ref, unref and free methods as (skip).

https://bugzilla.gnome.org/show_bug.cgi?id=590808
2011-10-15 17:54:41 -04:00
Christian Persch
a57c9148cf GKeyFile: Add refcounting API
Adds g_key_file_ref and g_key_file_unref, to be used by a future
GKeyFile boxed type for language bindings.

Based on the patch by Christian Persch and Emmanuele Bassi.

Author: Christian Persch
Signed-off-by: Johan Dahlin
Signed-off-by: Giovanni Campagna

https://bugzilla.gnome.org/show_bug.cgi?id=590808
2011-10-15 17:44:45 -04:00
Matthias Clasen
117e534091 Misc doc formatting fixes 2011-10-15 17:00:56 -04:00
Matthias Clasen
94c246e8e3 Add tests for new g_environ_ functions 2011-10-15 16:28:07 -04:00
Matthias Clasen
7a9987d35d Move environment-related functions into their own files
gutils.[hc] is a bit of a grab bag, so lets start cleaning
things up by moving all the environment-related functions
into separate genviron.[hc] files.

The private _g_getenv_nomalloc has been moved to its sole caller.
2011-10-15 16:13:08 -04:00
Dan Winship
409d93148f gutils: Add functions for working with environment arrays
When spawning a child process, it is not safe to call setenv() before
the fork() (because setenv() isn't thread-safe), but it's also not
safe to call it after the fork() (because it's not async-signal-safe).
So the only safe way to alter the environment for a child process from
a threaded program is to pass a fully-formed envp array to
exec*/g_spawn*/etc.

So, add g_environ_getenv(), g_environ_setenv(), and
g_environ_unsetenv(), which act like their namesakes, but work on
arbitrary arrays rather than working directly on the environment.

http://bugzilla.gnome.org/show_bug.cgi?id=659326
2011-10-15 15:54:45 -04:00
Ryan Lortie
5ff803d91f Add to the pitfalls: fork() and daemon() 2011-10-15 13:27:46 -04:00
Matthias Clasen
6651bd221e Expand thread docs a bit
Add some discussion of pitfalls of threaded programming.
2011-10-15 13:04:20 -04:00
Matthias Clasen
e4699af8eb Documentation tweaks 2011-10-15 11:37:03 -04:00
Ryan Lortie
3fe3fdd75a Check for "our" threads in some places
Don't allow g_thread_join() to be called on or g_thread_exit() to be
called from within threads that were not created by GLib.  Document
this.
2011-10-15 09:48:42 -04:00
Ryan Lortie
11f3684b71 gtk-doc g_thread_ref() and g_thread_unref() 2011-10-15 09:48:22 -04:00
Ryan Lortie
e75e9c3044 Rename g_thread_try to g_thread_try_new 2011-10-15 09:48:10 -04:00
Matthias Clasen
4417e77f17 Add atomic test to TEST_PROGS 2011-10-15 00:56:08 -04:00
Matthias Clasen
482bb38748 Documentation additions 2011-10-15 00:26:02 -04:00
Matthias Clasen
8bc8cd7aa0 Improve test coverage 2011-10-15 00:09:20 -04:00
Matthias Clasen
52321def8f Add a test involving g_thread_ref/unref
Also, fix the resource-limit test to properly unset RLIMIT_NPROC.
2011-10-14 23:20:06 -04:00
Matthias Clasen
5ddcc284e8 Minor doc clarifications 2011-10-14 23:00:17 -04:00
Ryan Lortie
7ab25865f2 Stop checking for fork() across GMainContext
01ed78d525 introduced assertion checks for
creating a main context, forking, and attempting to use the main context
from the child side of the fork.

Some code (such as gnome-keyring-daemon) daemonise after calling
GMainContext.  That's probably still mostly safe since we still only
have one side of the fork touching the context afterwards.

This use case is still troubling, however, since if any worker threads
have been created at the time of the fork(), we could end up in the
classic situation of leaving some mutexes in a locked state when the
other threads disappear from the copy of the image that the child gets.

This will require some deeper thinking...
2011-10-14 20:01:22 -04:00
Ryan Lortie
51773c6c64 Mask all signals in GLib worker thread
Some code using GLib (gnome-keyring-daemon, for example) assumes that
they can catch signals by masking them out in the main thread and
calling sigwait() from a worker.

The problem is that our new worker thread catches the signals before
sigwait() has a chance and the default action occurs (typically
resulting in program termination).

If we mask all the signals in our worker, then this can't happen.
2011-10-14 20:01:22 -04:00
Ryan Lortie
14e3b12823 g_cond_timed_wait: support NULL time parameter
It was undocumented, but this used to mean "wait forever".  Looks like
we have some uses of this internally and there may be others in the
wild...
2011-10-14 00:00:14 -04:00
Ryan Lortie
4033c616ff GCond: use monotonic time for timed waits
Switch GCond to using monotonic time for timed waits by introducing a
new API based on monotonic time in a gint64: g_cond_wait_until().

Deprecate the old API based on wallclock time in a GTimeVal.

Fix up the gtk-doc for GCond while we're at it: update the examples to
use static-allocated GCond and GMutex and clarify some things a bit.
Also explain the rationale behind using an absolute time instead of a
relative time.
2011-10-13 23:44:17 -04:00
Ryan Lortie
3ebdb4d46a gutils: stop using GStaticPrivate
This was our last internal use.
2011-10-13 09:14:57 -04:00
Ryan Lortie
62fe053268 Revert "make struct _GThread private"
This reverts commit d904612100.

glibmm touches the contents of GThread, so this broke their build.
2011-10-13 09:00:54 -04:00
Ryan Lortie
d904612100 make struct _GThread private
Hide the definition of struct _GThread in gthreadprivate.h for now.

This is possibly an API break -- although the structure contents were
undocumented and it was not safe to access them in a meaningful way,
someone may have tried to do it anyway.  We'll leave it here for a while
to see if it causes any problems.

Avoid merging its contents with GRealThread for now, just incase we need
to expose it again.
2011-10-13 01:34:08 -04:00
Ryan Lortie
b1cc2579c1 tidy up gthreadprivate.h
Remove some unused includes, too.
2011-10-13 01:22:51 -04:00
Ryan Lortie
332f74a2fc drop g_thread_new_full()
We'll hold out on this until someone has a really convincing reason for
why they need to control the stack size.

If we do decide to add it back, it should probably have a name like
_new_with_stack_size(), not _full().
2011-10-13 01:17:36 -04:00
Ryan Lortie
430c5635f2 g_thread_new: never fail
Remove the GError argument from g_thread_new() and abort on failure.
Introduce g_thread_try() for those who want to handle failure.
2011-10-13 01:00:57 -04:00
Ryan Lortie
015f4b4513 thread: nuke the concept of 'joinable'
And remove the 'joinable' argument from g_thread_new() and
g_thread_new_full().

Change the wording in the docs.  Clarify expectations for
(deprecated) g_thread_create().
2011-10-13 00:43:33 -04:00
Ryan Lortie
b0e73ca390 GThread: make refcounting public 2011-10-13 00:29:04 -04:00
Ryan Lortie
62be9365d9 thread: simplify 'free' process
GThread is freed using some very slightly confusing logic: if the thread
was created 'joinable', then the structure is freed after the join()
call succeeds (since we know the thread has exited).  If the thread was
not created 'joinable' then the free is when the thread quits (since we
know 'join' will not be called later).

Move to a straight ref-counting system: 1 ref owned by the thread and 1
extra ref if the thread is joinable.  Both thread quit and joining will
decrease the refcount by 1.
2011-10-13 00:18:17 -04:00
Ryan Lortie
becb4b820f remove 'joinable' parameter to backends
Both backends are now oblivious to the concept of joinability, so don't
bother passing the parameter.
2011-10-13 00:01:28 -04:00
Ryan Lortie
dbf20d585f posix threads: joinable tweaks
Make the POSIX backend a little bit more like the win32 one in terms of
how we deal with joinability.

Calling g_system_thread_join() is now optional, and
g_system_thread_wait() can be safely called by multiple threads.

There is no longer any internal concept of joinability.
2011-10-12 23:40:02 -04:00
Ryan Lortie
f970dfc734 tests: don't #include <sys/resource.h> on win32 2011-10-12 23:25:12 -04:00
Ryan Lortie
45736d33bb win32 threads: simplify
Merge the GThreadData with the GThreadWin32 struct.  Drop the extra TLS
variable.

Close the handle on _free(), which means that there is no leak if
g_system_thread_join() isn't called.

Remove all internal concept of joinability.
2011-10-12 23:22:31 -04:00
Ryan Lortie
dfd466979b Only g_system_thread_free() our own threads
Keep track of if we created a thread for ourselves or if the GThread*
was allocated in response to g_thread_self() on a previously-unknown
thread.

Only call g_system_thread_free() in the first case.
2011-10-12 23:19:06 -04:00
Ryan Lortie
a5800ef336 Finish killing off GSystemThread 2011-10-12 23:04:15 -04:00
Ryan Lortie
e0c9757b9b win32 threads: use our own data, not system_thread
Stop using the generic system_thread field in GRealThread.  Use our own
pointer instead.
2011-10-12 22:53:52 -04:00
Ryan Lortie
67e28068e1 win32: fix function name clash 2011-10-12 22:49:39 -04:00
Ryan Lortie
2010f7f955 posix threads: use our own system_thread
Wrap GRealThread in a GThreadPosix that includes its own pthread_t field
called "system_thread" and use that instead of the generic field in
GRealThread.
2011-10-12 22:43:22 -04:00
Ryan Lortie
2f5486f020 thread creation: Simplify error handling
Instead of always returning non-NULL and finding out about errors via
the GError*, return NULL from the backend in the event of an error.
2011-10-12 22:43:22 -04:00
Ryan Lortie
e14a3746db Combine g_sytem_thread_{new,create}() 2011-10-12 22:43:22 -04:00
Ryan Lortie
a3f82c847f g_system_thread_create: drop 'data' arg
Since it's now always the same as the 'thread' arg.
2011-10-12 22:43:22 -04:00
Ryan Lortie
3237eaf5d5 g_system_thread_create: SystemThread -> RealThread
Just like g_system_thread_wait().
2011-10-12 22:43:22 -04:00
Matthias Clasen
6613b2f8fd Move more docs inline 2011-10-12 22:29:53 -04:00
Ryan Lortie
dc3727cc5f g_system_thread_join: rename to _wait() 2011-10-12 22:15:46 -04:00
Ryan Lortie
4bb968e335 g_system_thread_join: take GRealThread *
Make g_system_thread_join take the GRealThread* instead of a
GSystemThread.
2011-10-12 22:14:38 -04:00
Ryan Lortie
e064c9bfec thread: delegate allocation of GThread to backends
Add g_system_thread_new() and g_system_thread_free(), implemented with
GSlice.  Use those instead of g_new() and g_free().

Presently, the backends are both doing the same thing.  This will change
soon.
2011-10-12 22:04:39 -04:00