mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-05 00:46:16 +01:00
Fix some C99isms. (#390913, Kazuki Iwamoto)
2006-12-31 Matthias Clasen <mclasen@redhat.com> * glib/gslice.c: Fix some C99isms. (#390913, Kazuki Iwamoto) svn path=/trunk/; revision=5183
This commit is contained in:
parent
2c79668714
commit
e319147a9e
@ -1,3 +1,7 @@
|
|||||||
|
2006-12-31 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* glib/gslice.c: Fix some C99isms. (#390913, Kazuki Iwamoto)
|
||||||
|
|
||||||
Fri Dec 29 13:28:07 2006 Tim Janik <timj@imendio.com>
|
Fri Dec 29 13:28:07 2006 Tim Janik <timj@imendio.com>
|
||||||
|
|
||||||
* glib/gslice.c: turned detection of too late g_thread_init() calls
|
* glib/gslice.c: turned detection of too late g_thread_init() calls
|
||||||
|
@ -374,9 +374,11 @@ _g_slice_thread_init_nomessage (void)
|
|||||||
/* we may not use g_error() or friends here */
|
/* we may not use g_error() or friends here */
|
||||||
if (sys_page_size)
|
if (sys_page_size)
|
||||||
{
|
{
|
||||||
|
const char *pname;
|
||||||
|
|
||||||
/* mem_error ("g_thread_init() must be called before GSlice is used, memory corrupted..."); */
|
/* mem_error ("g_thread_init() must be called before GSlice is used, memory corrupted..."); */
|
||||||
fputs ("\n***MEMORY-WARNING***: ", stderr);
|
fputs ("\n***MEMORY-WARNING***: ", stderr);
|
||||||
const char *pname = g_get_prgname();
|
pname = g_get_prgname();
|
||||||
fprintf (stderr, "%s[%u]: GSlice: ", pname ? pname : "", getpid());
|
fprintf (stderr, "%s[%u]: GSlice: ", pname ? pname : "", getpid());
|
||||||
fputs ("g_thread_init() must be called before all other GLib functions; "
|
fputs ("g_thread_init() must be called before all other GLib functions; "
|
||||||
"memory corruption due to late invocation of g_thread_init() has been detected; "
|
"memory corruption due to late invocation of g_thread_init() has been detected; "
|
||||||
@ -1204,10 +1206,12 @@ smc_notify_free (void *pointer,
|
|||||||
size_t size)
|
size_t size)
|
||||||
{
|
{
|
||||||
size_t adress = (size_t) pointer;
|
size_t adress = (size_t) pointer;
|
||||||
|
SmcVType real_size;
|
||||||
|
gboolean found_one;
|
||||||
|
|
||||||
if (!pointer)
|
if (!pointer)
|
||||||
return 1; /* ignore */
|
return 1; /* ignore */
|
||||||
SmcVType real_size;
|
found_one = smc_tree_lookup (adress, &real_size);
|
||||||
gboolean found_one = smc_tree_lookup (adress, &real_size);
|
|
||||||
if (!found_one)
|
if (!found_one)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "GSlice: MemChecker: attempt to release non-allocated block: %p size=%zu\n", pointer, size);
|
fprintf (stderr, "GSlice: MemChecker: attempt to release non-allocated block: %p size=%zu\n", pointer, size);
|
||||||
@ -1294,8 +1298,12 @@ static void
|
|||||||
smc_tree_insert (SmcKType key,
|
smc_tree_insert (SmcKType key,
|
||||||
SmcVType value)
|
SmcVType value)
|
||||||
{
|
{
|
||||||
|
unsigned int ix0, ix1;
|
||||||
|
SmcEntry *entry;
|
||||||
|
|
||||||
g_mutex_lock (smc_tree_mutex);
|
g_mutex_lock (smc_tree_mutex);
|
||||||
unsigned int ix0 = SMC_TRUNK_HASH (key), ix1 = SMC_BRANCH_HASH (key);
|
ix0 = SMC_TRUNK_HASH (key);
|
||||||
|
ix1 = SMC_BRANCH_HASH (key);
|
||||||
if (!smc_tree_root)
|
if (!smc_tree_root)
|
||||||
{
|
{
|
||||||
smc_tree_root = calloc (SMC_TRUNK_COUNT, sizeof (smc_tree_root[0]));
|
smc_tree_root = calloc (SMC_TRUNK_COUNT, sizeof (smc_tree_root[0]));
|
||||||
@ -1308,7 +1316,7 @@ smc_tree_insert (SmcKType key,
|
|||||||
if (!smc_tree_root[ix0])
|
if (!smc_tree_root[ix0])
|
||||||
smc_tree_abort (errno);
|
smc_tree_abort (errno);
|
||||||
}
|
}
|
||||||
SmcEntry *entry = smc_tree_branch_lookup_nearest_L (&smc_tree_root[ix0][ix1], key);
|
entry = smc_tree_branch_lookup_nearest_L (&smc_tree_root[ix0][ix1], key);
|
||||||
if (!entry || /* need create */
|
if (!entry || /* need create */
|
||||||
entry >= smc_tree_root[ix0][ix1].entries + smc_tree_root[ix0][ix1].n_entries || /* need append */
|
entry >= smc_tree_root[ix0][ix1].entries + smc_tree_root[ix0][ix1].n_entries || /* need append */
|
||||||
entry->key != key) /* need insert */
|
entry->key != key) /* need insert */
|
||||||
@ -1322,11 +1330,11 @@ static gboolean
|
|||||||
smc_tree_lookup (SmcKType key,
|
smc_tree_lookup (SmcKType key,
|
||||||
SmcVType *value_p)
|
SmcVType *value_p)
|
||||||
{
|
{
|
||||||
|
SmcEntry *entry = NULL;
|
||||||
unsigned int ix0 = SMC_TRUNK_HASH (key), ix1 = SMC_BRANCH_HASH (key);
|
unsigned int ix0 = SMC_TRUNK_HASH (key), ix1 = SMC_BRANCH_HASH (key);
|
||||||
gboolean found_one = FALSE;
|
gboolean found_one = FALSE;
|
||||||
*value_p = 0;
|
*value_p = 0;
|
||||||
g_mutex_lock (smc_tree_mutex);
|
g_mutex_lock (smc_tree_mutex);
|
||||||
SmcEntry *entry = NULL;
|
|
||||||
if (smc_tree_root && smc_tree_root[ix0])
|
if (smc_tree_root && smc_tree_root[ix0])
|
||||||
{
|
{
|
||||||
entry = smc_tree_branch_lookup_nearest_L (&smc_tree_root[ix0][ix1], key);
|
entry = smc_tree_branch_lookup_nearest_L (&smc_tree_root[ix0][ix1], key);
|
||||||
|
Loading…
Reference in New Issue
Block a user