got rid of outdated dmalloc support. provide g_try_malloc() and

Thu Dec 28 10:21:46 2000  Tim Janik  <timj@gtk.org>

        * gmem.[hc]: got rid of outdated dmalloc support. provide g_try_malloc()
        and g_try_realloc() which _may_ fail and return NULL.
        nuked g_mem_check(), provided GMemVTable for memory function
        virtualization, alterable at program startup with g_mem_set_vtable().
        provided glib_mem_profiler_table and g_mem_profile() to support limited
        profiling information out of the box (uses mprotect() for free()ed areas
        on linux).
        provide globally visible G_MEM_ALIGN.
        buncha cleanups.

        * docs/macros.txt: file to get a clue about the various configuration
        macros.

        * docs/debugging.txt: explain debugging traps.

        * configure.in: got rid of --enable-mem-check and --enable-mem-profile,
        define GLIB_SIZEOF_VOID_P and GLIB_SIZEOF_LONG. check malloc prototypes
        and define SANE_MALLOC_PROTOS is we can use them.
        <boy, is this file a mess>

        * gutils.c, gscanner.c: fix up compatibility warnings, use g_message().


Thu Dec 28 11:36:44 2000  Tim Janik  <timj@gtk.org>

        * gbsearcharray.c (upper_power2): disable G_BSEARCH_ALIGN_POWER2
        fucntionality if DISABLE_MEM_POOLS is defined.

        * gtype.c: honour DISABLE_MEM_POOLS.

        * gsignal.c (g_signal_init): flag signal key bsearch array with
        G_BSEARCH_ALIGN_POWER2 to avoid excessive growth time. honour
        DISABLE_MEM_POOLS.

        * gparam.h: added G_PARAM_READWRITE alias for (G_PARAM_READABLE |
                                                       G_PARAM_WRITABLE).
This commit is contained in:
Tim Janik 2000-12-29 02:16:51 +00:00 committed by Tim Janik
parent ab31e0c3ce
commit 782a8e2e7c
31 changed files with 1845 additions and 1158 deletions

View File

@ -1,3 +1,27 @@
Thu Dec 28 10:21:46 2000 Tim Janik <timj@gtk.org>
* gmem.[hc]: got rid of outdated dmalloc support. provide g_try_malloc()
and g_try_realloc() which _may_ fail and return NULL.
nuked g_mem_check(), provided GMemVTable for memory function
virtualization, alterable at program startup with g_mem_set_vtable().
provided glib_mem_profiler_table and g_mem_profile() to support limited
profiling information out of the box (uses mprotect() for free()ed areas
on linux).
provide globally visible G_MEM_ALIGN.
buncha cleanups.
* docs/macros.txt: file to get a clue about the various configuration
macros.
* docs/debugging.txt: explain debugging traps.
* configure.in: got rid of --enable-mem-check and --enable-mem-profile,
define GLIB_SIZEOF_VOID_P and GLIB_SIZEOF_LONG. check malloc prototypes
and define SANE_MALLOC_PROTOS is we can use them.
<boy, is this file a mess>
* gutils.c, gscanner.c: fix up compatibility warnings, use g_message().
2000-12-27 Tor Lillqvist <tml@iki.fi>
* README.win32: Update.

View File

@ -1,3 +1,27 @@
Thu Dec 28 10:21:46 2000 Tim Janik <timj@gtk.org>
* gmem.[hc]: got rid of outdated dmalloc support. provide g_try_malloc()
and g_try_realloc() which _may_ fail and return NULL.
nuked g_mem_check(), provided GMemVTable for memory function
virtualization, alterable at program startup with g_mem_set_vtable().
provided glib_mem_profiler_table and g_mem_profile() to support limited
profiling information out of the box (uses mprotect() for free()ed areas
on linux).
provide globally visible G_MEM_ALIGN.
buncha cleanups.
* docs/macros.txt: file to get a clue about the various configuration
macros.
* docs/debugging.txt: explain debugging traps.
* configure.in: got rid of --enable-mem-check and --enable-mem-profile,
define GLIB_SIZEOF_VOID_P and GLIB_SIZEOF_LONG. check malloc prototypes
and define SANE_MALLOC_PROTOS is we can use them.
<boy, is this file a mess>
* gutils.c, gscanner.c: fix up compatibility warnings, use g_message().
2000-12-27 Tor Lillqvist <tml@iki.fi>
* README.win32: Update.

View File

@ -1,3 +1,27 @@
Thu Dec 28 10:21:46 2000 Tim Janik <timj@gtk.org>
* gmem.[hc]: got rid of outdated dmalloc support. provide g_try_malloc()
and g_try_realloc() which _may_ fail and return NULL.
nuked g_mem_check(), provided GMemVTable for memory function
virtualization, alterable at program startup with g_mem_set_vtable().
provided glib_mem_profiler_table and g_mem_profile() to support limited
profiling information out of the box (uses mprotect() for free()ed areas
on linux).
provide globally visible G_MEM_ALIGN.
buncha cleanups.
* docs/macros.txt: file to get a clue about the various configuration
macros.
* docs/debugging.txt: explain debugging traps.
* configure.in: got rid of --enable-mem-check and --enable-mem-profile,
define GLIB_SIZEOF_VOID_P and GLIB_SIZEOF_LONG. check malloc prototypes
and define SANE_MALLOC_PROTOS is we can use them.
<boy, is this file a mess>
* gutils.c, gscanner.c: fix up compatibility warnings, use g_message().
2000-12-27 Tor Lillqvist <tml@iki.fi>
* README.win32: Update.

View File

@ -1,3 +1,27 @@
Thu Dec 28 10:21:46 2000 Tim Janik <timj@gtk.org>
* gmem.[hc]: got rid of outdated dmalloc support. provide g_try_malloc()
and g_try_realloc() which _may_ fail and return NULL.
nuked g_mem_check(), provided GMemVTable for memory function
virtualization, alterable at program startup with g_mem_set_vtable().
provided glib_mem_profiler_table and g_mem_profile() to support limited
profiling information out of the box (uses mprotect() for free()ed areas
on linux).
provide globally visible G_MEM_ALIGN.
buncha cleanups.
* docs/macros.txt: file to get a clue about the various configuration
macros.
* docs/debugging.txt: explain debugging traps.
* configure.in: got rid of --enable-mem-check and --enable-mem-profile,
define GLIB_SIZEOF_VOID_P and GLIB_SIZEOF_LONG. check malloc prototypes
and define SANE_MALLOC_PROTOS is we can use them.
<boy, is this file a mess>
* gutils.c, gscanner.c: fix up compatibility warnings, use g_message().
2000-12-27 Tor Lillqvist <tml@iki.fi>
* README.win32: Update.

View File

@ -1,3 +1,27 @@
Thu Dec 28 10:21:46 2000 Tim Janik <timj@gtk.org>
* gmem.[hc]: got rid of outdated dmalloc support. provide g_try_malloc()
and g_try_realloc() which _may_ fail and return NULL.
nuked g_mem_check(), provided GMemVTable for memory function
virtualization, alterable at program startup with g_mem_set_vtable().
provided glib_mem_profiler_table and g_mem_profile() to support limited
profiling information out of the box (uses mprotect() for free()ed areas
on linux).
provide globally visible G_MEM_ALIGN.
buncha cleanups.
* docs/macros.txt: file to get a clue about the various configuration
macros.
* docs/debugging.txt: explain debugging traps.
* configure.in: got rid of --enable-mem-check and --enable-mem-profile,
define GLIB_SIZEOF_VOID_P and GLIB_SIZEOF_LONG. check malloc prototypes
and define SANE_MALLOC_PROTOS is we can use them.
<boy, is this file a mess>
* gutils.c, gscanner.c: fix up compatibility warnings, use g_message().
2000-12-27 Tor Lillqvist <tml@iki.fi>
* README.win32: Update.

View File

@ -1,3 +1,27 @@
Thu Dec 28 10:21:46 2000 Tim Janik <timj@gtk.org>
* gmem.[hc]: got rid of outdated dmalloc support. provide g_try_malloc()
and g_try_realloc() which _may_ fail and return NULL.
nuked g_mem_check(), provided GMemVTable for memory function
virtualization, alterable at program startup with g_mem_set_vtable().
provided glib_mem_profiler_table and g_mem_profile() to support limited
profiling information out of the box (uses mprotect() for free()ed areas
on linux).
provide globally visible G_MEM_ALIGN.
buncha cleanups.
* docs/macros.txt: file to get a clue about the various configuration
macros.
* docs/debugging.txt: explain debugging traps.
* configure.in: got rid of --enable-mem-check and --enable-mem-profile,
define GLIB_SIZEOF_VOID_P and GLIB_SIZEOF_LONG. check malloc prototypes
and define SANE_MALLOC_PROTOS is we can use them.
<boy, is this file a mess>
* gutils.c, gscanner.c: fix up compatibility warnings, use g_message().
2000-12-27 Tor Lillqvist <tml@iki.fi>
* README.win32: Update.

View File

@ -1,3 +1,27 @@
Thu Dec 28 10:21:46 2000 Tim Janik <timj@gtk.org>
* gmem.[hc]: got rid of outdated dmalloc support. provide g_try_malloc()
and g_try_realloc() which _may_ fail and return NULL.
nuked g_mem_check(), provided GMemVTable for memory function
virtualization, alterable at program startup with g_mem_set_vtable().
provided glib_mem_profiler_table and g_mem_profile() to support limited
profiling information out of the box (uses mprotect() for free()ed areas
on linux).
provide globally visible G_MEM_ALIGN.
buncha cleanups.
* docs/macros.txt: file to get a clue about the various configuration
macros.
* docs/debugging.txt: explain debugging traps.
* configure.in: got rid of --enable-mem-check and --enable-mem-profile,
define GLIB_SIZEOF_VOID_P and GLIB_SIZEOF_LONG. check malloc prototypes
and define SANE_MALLOC_PROTOS is we can use them.
<boy, is this file a mess>
* gutils.c, gscanner.c: fix up compatibility warnings, use g_message().
2000-12-27 Tor Lillqvist <tml@iki.fi>
* README.win32: Update.

View File

@ -1,3 +1,27 @@
Thu Dec 28 10:21:46 2000 Tim Janik <timj@gtk.org>
* gmem.[hc]: got rid of outdated dmalloc support. provide g_try_malloc()
and g_try_realloc() which _may_ fail and return NULL.
nuked g_mem_check(), provided GMemVTable for memory function
virtualization, alterable at program startup with g_mem_set_vtable().
provided glib_mem_profiler_table and g_mem_profile() to support limited
profiling information out of the box (uses mprotect() for free()ed areas
on linux).
provide globally visible G_MEM_ALIGN.
buncha cleanups.
* docs/macros.txt: file to get a clue about the various configuration
macros.
* docs/debugging.txt: explain debugging traps.
* configure.in: got rid of --enable-mem-check and --enable-mem-profile,
define GLIB_SIZEOF_VOID_P and GLIB_SIZEOF_LONG. check malloc prototypes
and define SANE_MALLOC_PROTOS is we can use them.
<boy, is this file a mess>
* gutils.c, gscanner.c: fix up compatibility warnings, use g_message().
2000-12-27 Tor Lillqvist <tml@iki.fi>
* README.win32: Update.

View File

@ -44,3 +44,4 @@
ignoring punctuation (such as underscores). */
#undef USE_LIBICONV
#undef SANE_MALLOC_PROTOS

View File

@ -102,8 +102,6 @@ esac[]dnl
dnl declare --enable-* args and collect ac_help strings
AC_ARG_ENABLE(debug, [ --enable-debug=[no/minimum/yes] turn on debugging [default=$debug_default]],,enable_debug=$debug_default)
AC_ARG_ENABLE(msg-prefix, [ --enable-msg-prefix turn on program name and PID prefixing of messages and warnings],,enable_msg_prefix=no)
AC_ARG_ENABLE(mem_check, [ --enable-mem-check turn on malloc/free sanity checking [default=no]],,enable_mem_check=no)
AC_ARG_ENABLE(mem_profile, [ --enable-mem-profile turn on malloc profiling atexit [default=no]],,enable_mem_profile=no)
AC_ARG_ENABLE(gc_friendly, [ --enable-gc-friendly turn on garbage collector friendliness [default=no]],,enable_gc_friendly=no)
AC_ARG_ENABLE(mem_pools, [ --disable-mem-pools disable all glib memory pools],,disable_mem_pools=no)
AC_ARG_ENABLE(ansi, [ --enable-ansi turn on strict ansi [default=no]],
@ -116,23 +114,17 @@ if test "x$enable_threads" != "xyes"; then
enable_threads=no
fi
AC_MSG_CHECKING(whether to enable memory checking)
if test "x$enable_mem_check" = "xyes"; then
AC_DEFINE(ENABLE_MEM_CHECK, 1, [Whether to enable memory checking])
AC_SUBST(ENABLE_MEM_CHECK)
AC_MSG_RESULT(yes)
if test "x$enable_debug" = "xyes"; then
test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
GLIB_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
else
AC_MSG_RESULT(no)
if test "x$enable_debug" = "xno"; then
GLIB_DEBUG_FLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
fi
fi
AC_MSG_CHECKING(whether to enable memory profiling)
if test "x$enable_mem_profile" = "xyes"; then
AC_DEFINE(ENABLE_MEM_PROFILE, 1, [Whether to enable memory profiling])
AC_SUBST(ENABLE_MEM_PROFILE)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_DEFINE_UNQUOTED(G_COMPILED_WITH_DEBUGGING, "${enable_debug}",
[Whether glib was compiled with debugging enabled])
AC_MSG_CHECKING(whether to enable garbage collector friendliness)
if test "x$enable_gc_friendly" = "xyes"; then
@ -152,19 +144,6 @@ else
AC_MSG_RESULT(yes)
fi
if test "x$enable_debug" = "xyes"; then
test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
GLIB_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
else
if test "x$enable_debug" = "xno"; then
GLIB_DEBUG_FLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
fi
fi
AC_DEFINE_UNQUOTED(G_COMPILED_WITH_DEBUGGING, "${enable_debug}",
[Whether glib was compiled with debugging enabled])
if test "x$enable_msg_prefix" = "xyes"; then
AC_DEFINE_UNQUOTED(G_ENABLE_MSG_PREFIX, 1,
[Enable prefixing of error messages with program names])
@ -290,6 +269,33 @@ dnl long doubles were not used, and a portability problem
dnl AC_C_LONG_DOUBLE
AC_C_CONST
dnl ok, here we try to check whether the systems prototypes for
dnl malloc and friends actually match the prototypes provided
dnl by gmem.h (keep in sync). i currently only know how to check
dnl this reliably with gcc (-Werror), improvements for other
dnl compilers are apprechiated.
SANE_MALLOC_PROTOS=no
AC_MSG_CHECKING([if malloc() and friends prototypes are gmem.h compatible])
glib_save_CFLAGS=$CFLAGS
if test "x$GCC" = "xyes"; then
CFLAGS="$CFLAGS -Werror"
AC_TRY_COMPILE([#include <stdlib.h>], [
void* (*my_calloc_p) (size_t, size_t) = calloc;
void* (*my_malloc_p) (size_t) = malloc;
void (*my_free_p) (void*) = free;
void* (*my_realloc_p) (void*, size_t) = realloc;
my_calloc_p = 0;
my_malloc_p = 0;
my_free_p = 0;
my_realloc_p = 0;
],
AC_DEFINE(SANE_MALLOC_PROTOS)
SANE_MALLOC_PROTOS=yes)
fi
AC_MSG_RESULT($SANE_MALLOC_PROTOS)
CFLAGS=$glib_save_CFLAGS
dnl AC_C_INLINE is useless to us since it bails out too early, we need to
dnl truely know which ones of `inline', `__inline' and `__inline__' are
dnl actually supported.
@ -1374,6 +1380,13 @@ _______EOF
fi
fi
cat >>$outfile <<_______EOF
#define GLIB_SIZEOF_VOID_P $glib_void_p
#define GLIB_SIZEOF_LONG $glib_long
_______EOF
case x$glib_size_t in
x2) echo "typedef gint16 gssize;" >> $outfile
echo "typedef guint16 gsize;" >> $outfile
@ -1625,6 +1638,8 @@ $ac_cv_sizeof_long_long)
;;
esac
glib_size_t=$glib_cv_sizeof_size_t
glib_void_p=$ac_cv_sizeof_long
glib_long=$ac_cv_sizeof_void_p
gintbits=`expr $ac_cv_sizeof_int \* 8`
glongbits=`expr $ac_cv_sizeof_long \* 8`

28
docs/debugging.txt Normal file
View File

@ -0,0 +1,28 @@
G_BREAKPOINT () traps for the debugger
======================================
Some code portions contain trap variables that can be set during
debugging time if G_ENABLE_DEBUG has been defined upon compilation
(use the --enable-debug=yes option to configure for this, macros.txt
covers more details).
Such traps lead to immediate code halts to examine the current
program state and backtrace.
Currently, the following trap variables exist:
static volatile gulong glib_trap_free_size;
static volatile gulong glib_trap_realloc_size;
static volatile gulong glib_trap_malloc_size;
If set to a size > 0, g_free(), g_realloc() and g_malloc()
respectively, will be intercepted if the size matches the
size of the corresponding memory block to free/reallocate/allocate.
This will only work with g_mem_set_vtable (glib_mem_profiler_table)
upon startup though, because memory profiling is required to match
on the memory block sizes.
static volatile GObject *glib_trap_object_ref;
If set to a valid object pointer, ref/unref will be intercepted
with G_BREAKPOINT ();
2000/12/28 Tim Janik

79
docs/macros.txt Normal file
View File

@ -0,0 +1,79 @@
GLib's configure options and corresponding macros
=================================================
--enable-debug=no
-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS
--enable-debug=minimum [default for stable branches]
none
--enable-debug=yes [default for development branches]
-DG_ENABLE_DEBUG -g
--enable-gc-friendly=yes
#define ENABLE_GC_FRIENDLY 1
--disable-mem-pools=yes
#define DISABLE_MEM_POOLS 1
Besides these, there are some local feature specific options, but my main
focus here is to concentrate on macros that affect overall GLib behaviour
and/or third party code.
Notes on GLib's internal and global macros
==========================================
ENABLE_GC_FRIENDLY
Newly allocated memory that isn't directly initialized, as well
as memory being freed should be reset to 0. The point here is to
allow memory checkers and similar programs that use bohem GC alike
algorithms to produce more accurate results.
DISABLE_MEM_POOLS
Many small chunks of memory are often allocated via collective pools
in GLib and are cached after release to speed up reallocations.
For sparse memory systems this behaviour is often inferior, so
memory pools can be disabled to avoid excessive caching and force
atomic maintenance of chunks through the g_malloc/g_free.
Code currently affected by this macro:
- GList, GSList, GNode allocations
- GMemChunks become basically non-effective
- GSignal disables all caching (potentially very slow)
- GType doesn't honour the GTypeInfo n_preallocs field anymore
- the GBSearchArray flag G_BSEARCH_ALIGN_POWER2 becomes non-functional
G_DISABLE_ASSERT
The g_assert() and g_assert_not_reached() become non-functional
with this define. The motivation is to speed up end-user apps by
avoiding expensive checks.
This macro can affect third-party code. --enable-debug=no will only
disable the assertion macros for GLib itself, but third-party code
that passes -DG_DISABLE_ASSERT to the compiler upon its own build
will end up with the non-functional variants after including glib.h
as well.
NOTE: Code inside the assertion macros should not have side effects
that affect the operation of the program.
G_DISABLE_CHECKS
This macro is similar to G_DISABLE_ASSERT, it affects third-party
code as mentioned above and the NOTE about G_DISABLE_ASSERT applies
too. The macros that become non-functional here are
g_return_if_fail(), g_return_val_if_fail(), g_return_if_reached() and
g_return_val_if_reached().
Additionally the glib_mem_profiler_table and g_mem_profile() from
gmem.h become non-functional if this macro is supplied.
This macro also switches off certain checks in the GSignal code.
G_ENABLE_DEBUG
Quite a bit of additional debugging code is compiled into GLib for this
macro, and since it is a globally visible define, third-party code may
be affected by it similar to G_DISABLE_ASSERT.
The additional code executed/compiled for this macro currently involve:
- extra validity checks for GDate
- memory profiling traps in gmem.c (consult debugging.txt for details)
- BREAKPOINT abortion for fatal log levels in gmessage.c instead of
plain abort() to allow debuggers trapping and overriding them
- added verbosity of gscanner.c to catch deprecated code paths
- added verbosity of gutils.c to catch deprecated code paths
- object ref/unref traps (consult debugging.txt) and object bookkeeping
in gobject.c
- extra validity checks in gsignal.c
2000/12/28 Tim Janik

View File

@ -422,74 +422,6 @@ dates must be valid.
greater than zero if @lhs is greater than @rhs
<!-- ##### FUNCTION g_date_get_day ##### -->
<para>
Return the day of the month; the #GDate must be valid.
</para>
@date: Date to extract the day of the month from
@Returns: Day of the month
<!-- ##### FUNCTION g_date_get_month ##### -->
<para>
Accessor for the month of the year. Date must be valid.
</para>
@date: Date to get the month from
@Returns: A #GDateMonth
<!-- ##### FUNCTION g_date_get_year ##### -->
<para>
Accessor; returns the year of a #GDate. The date must be valid.
</para>
@date: Date
@Returns: Year in which the date falls
<!-- ##### FUNCTION g_date_get_julian ##### -->
<para>
Accessor, returns the Julian day or "serial number" of the #GDate. The
Julian day is simply the number of days since January 1, Year 1; i.e.,
January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2,
etc. Date must be valid.
</para>
@date: Date to extract the Julian day from
@Returns: Julian day
<!-- ##### FUNCTION g_date_get_weekday ##### -->
<para>
Returns the day of the week for a #GDate. The date must be valid.
</para>
@date: Date
@Returns: Day of the week as a #GDateWeekday
<!-- ##### FUNCTION g_date_get_day_of_year ##### -->
<para>
Return the day of the year, where Jan 1 is the first day of the
year. Date must be valid.
</para>
@date: Date to extract day of year from
@Returns: Day of the year
<!-- ##### FUNCTION g_date_get_days_in_month ##### -->
<para>
Return the number of days in a month, taking leap years into account.
</para>
@month: Month
@year: Year
@Returns: Number of days in @month during the year @year.
<!-- ##### FUNCTION g_date_is_first_of_month ##### -->
<para>
Returns TRUE if the date is on the first of a month. Date must be valid.
@ -517,56 +449,6 @@ Returns TRUE if the year is a leap year
@Returns: Boolean, if the year is a leap year
<!-- ##### FUNCTION g_date_get_monday_week_of_year ##### -->
<para>
Return the week of the year, where weeks are understood to start on
Monday. If the date is before the first Monday of the year, return
0. Date must be valid.
</para>
@date: Date to use
@Returns: Week of the year
<!-- ##### FUNCTION g_date_get_monday_weeks_in_year ##### -->
<para>
Return the number of weeks in the year, where weeks are taken to start
on Monday. Will be 52 or 53. Date must be valid. (Years always have 52
7-day periods, plus 1 or 2 extra days depending on whether it's a leap
year. This function is basically telling you how many Mondays are in
the year, i.e. there are 53 Mondays if one of the extra days happens
to be a Monday.)
</para>
@year: Year
@Returns: Number of Mondays in the year
<!-- ##### FUNCTION g_date_get_sunday_week_of_year ##### -->
<para>
Week of the year during which this date falls, if weeks are understood
to being on Sunday. Date must be valid. Can return 0 if the day is
before the first Sunday of the year.
</para>
@date: Date
@Returns: Week number
<!-- ##### FUNCTION g_date_get_sunday_weeks_in_year ##### -->
<para>
Return the number of weeks in the year, where weeks are taken to start
on Sunday. Will be 52 or 53. Date must be valid. (Years always have 52
7-day periods, plus 1 or 2 extra days depending on whether it's a leap
year. This function is basically telling you how many Sundays are in
the year, i.e. there are 53 Sundays if one of the extra days happens
to be a Sunday.)
</para>
@year: Year to count weeks in
@Returns: Number of weeks
<!-- ##### FUNCTION g_date_strftime ##### -->
<para>
Generate a printed representation of the date, in a locale-specific

View File

@ -1,3 +1,11 @@
<!-- ##### FUNCTION g_date_get_day ##### -->
<para>
Return the day of the month; the #GDate must be valid.
</para>
@date: Date to extract the day of the month from
@Returns: Day of the month
<!-- ##### FUNCTION g_markup_parse_context_parse ##### -->
<para>
@ -24,6 +32,19 @@
@callback_data:
@callback_funcs:
<!-- ##### FUNCTION g_date_get_sunday_weeks_in_year ##### -->
<para>
Return the number of weeks in the year, where weeks are taken to start
on Sunday. Will be 52 or 53. Date must be valid. (Years always have 52
7-day periods, plus 1 or 2 extra days depending on whether it's a leap
year. This function is basically telling you how many Sundays are in
the year, i.e. there are 53 Sundays if one of the extra days happens
to be a Sunday.)
</para>
@year: Year to count weeks in
@Returns: Number of weeks
<!-- ##### FUNCTION g_locale_to_utf8 ##### -->
<para>
@ -55,6 +76,26 @@
@source:
@can_recurse:
<!-- ##### FUNCTION g_date_get_days_in_month ##### -->
<para>
Return the number of days in a month, taking leap years into account.
</para>
@month: Month
@year: Year
@Returns: Number of days in @month during the year @year.
<!-- ##### FUNCTION g_date_get_julian ##### -->
<para>
Accessor, returns the Julian day or "serial number" of the #GDate. The
Julian day is simply the number of days since January 1, Year 1; i.e.,
January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2,
etc. Date must be valid.
</para>
@date: Date to extract the Julian day from
@Returns: Julian day
<!-- ##### MACRO pclose ##### -->
<para>
@ -192,6 +233,16 @@ See #G_PRIORITY_DEFAULT, #G_PRIORITY_DEFAULT_IDLE, #G_PRIORITY_HIGH,
@struct_size:
@Returns:
<!-- ##### FUNCTION g_date_get_monday_week_of_year ##### -->
<para>
Return the week of the year, where weeks are understood to start on
Monday. If the date is before the first Monday of the year, return
0. Date must be valid.
</para>
@date: Date to use
@Returns: Week of the year
<!-- ##### MACRO getpid ##### -->
<para>
@ -225,6 +276,14 @@ type of source.
@source:
@Returns:
<!-- ##### FUNCTION g_date_get_year ##### -->
<para>
Accessor; returns the year of a #GDate. The date must be valid.
</para>
@date: Date
@Returns: Year in which the date falls
<!-- ##### FUNCTION g_mkstemp ##### -->
<para>
@ -233,6 +292,14 @@ type of source.
@tmpl:
@Returns:
<!-- ##### FUNCTION g_date_get_month ##### -->
<para>
Accessor for the month of the year. Date must be valid.
</para>
@date: Date to get the month from
@Returns: A #GDateMonth
<!-- ##### FUNCTION g_main_context_get_poll_func ##### -->
<para>
@ -255,14 +322,6 @@ type of source.
</para>
<!-- ##### FUNCTION g_source_get_current_time ##### -->
<para>
</para>
@source:
@timeval:
<!-- ##### USER_FUNCTION GCompletionStrcmpFunc ##### -->
<para>
@ -272,6 +331,14 @@ type of source.
@s2:
@Returns:
<!-- ##### FUNCTION g_source_get_current_time ##### -->
<para>
</para>
@source:
@timeval:
<!-- ##### FUNCTION g_main_loop_new ##### -->
<para>
@ -309,6 +376,14 @@ type of source.
@array:
@compare_func:
<!-- ##### MACRO G_MODULE_SUFFIX ##### -->
<para>
Expands to the proper shared library suffix for the current platform
without the leading dot. For the most Unices and Linux this is "so",
for some HPUX versions this is "sl" and for Windows this is "dll".
</para>
<!-- ##### FUNCTION g_markup_parse_context_get_position ##### -->
<para>
@ -387,6 +462,15 @@ type of source.
@source:
@fd:
<!-- ##### FUNCTION g_date_get_day_of_year ##### -->
<para>
Return the day of the year, where Jan 1 is the first day of the
year. Date must be valid.
</para>
@date: Date to extract day of year from
@Returns: Day of the year
<!-- ##### FUNCTION g_tree_new_with_data ##### -->
<para>
@ -446,6 +530,16 @@ type of source.
@priority:
@Returns:
<!-- ##### FUNCTION g_date_get_sunday_week_of_year ##### -->
<para>
Week of the year during which this date falls, if weeks are understood
to being on Sunday. Date must be valid. Can return 0 if the day is
before the first Sunday of the year.
</para>
@date: Date
@Returns: Week number
<!-- ##### FUNCTION g_source_set_priority ##### -->
<para>
@ -473,6 +567,19 @@ type of source.
@user_data:
@Returns:
<!-- ##### FUNCTION g_date_get_monday_weeks_in_year ##### -->
<para>
Return the number of weeks in the year, where weeks are taken to start
on Monday. Will be 52 or 53. Date must be valid. (Years always have 52
7-day periods, plus 1 or 2 extra days depending on whether it's a leap
year. This function is basically telling you how many Mondays are in
the year, i.e. there are 53 Mondays if one of the extra days happens
to be a Monday.)
</para>
@year: Year
@Returns: Number of Mondays in the year
<!-- ##### FUNCTION g_main_context_find_source_by_user_data ##### -->
<para>
@ -496,6 +603,15 @@ type of source.
</para>
<!-- ##### MACRO g_rand_boolean ##### -->
<para>
Return a random #gboolean from @rand. This corresponds to a unbiased
coin toss.
</para>
@rand: a #GRand.
@Returns: a random #gboolean.
<!-- ##### FUNCTION g_io_create_watch ##### -->
<para>
@ -540,13 +656,6 @@ Removes a file descriptor from the list being polled.
</para>
<!-- ##### MACRO g_string ##### -->
<para>
Turns the argument into a string literal by using the '#' stringizing operator.
</para>
@x: text to convert to a literal string.
<!-- ##### FUNCTION g_idle_source_new ##### -->
<para>
@ -554,6 +663,13 @@ Turns the argument into a string literal by using the '#' stringizing operator.
@Returns:
<!-- ##### MACRO g_string ##### -->
<para>
Turns the argument into a string literal by using the '#' stringizing operator.
</para>
@x: text to convert to a literal string.
<!-- ##### FUNCTION g_main_context_pending ##### -->
<para>
@ -576,6 +692,14 @@ Turns the argument into a string literal by using the '#' stringizing operator.
@loop:
<!-- ##### FUNCTION g_date_get_weekday ##### -->
<para>
Returns the day of the week for a #GDate. The date must be valid.
</para>
@date: Date
@Returns: Day of the week as a #GDateWeekday
<!-- ##### MACRO read ##### -->
<para>
@ -611,6 +735,13 @@ There are no flags right now
@G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG:
<!-- ##### MACRO g_random_boolean ##### -->
<para>
Return a random #gboolean. This corresponds to a unbiased coin toss.
</para>
@Returns: a random #gboolean.
<!-- ##### FUNCTION g_slist_sort_with_data ##### -->
<para>

View File

@ -195,15 +195,6 @@ It is passed the #GModule structure.
@module: the module about to be unloaded.
<!-- ##### MACRO G_MODULE_SUFFIX ##### -->
<para>
Expands to the proper shared library suffix for the current platform
without the leading dot. For the most Unices and Linux this is "so",
for some HPUX versions this is "sl" and for Windows this is "dll".
</para>
<!-- ##### MACRO G_MODULE_EXPORT ##### -->
<para>
Used to declare functions exported by modules.

View File

@ -70,16 +70,6 @@ accessed through the g_rand_* functions.
@seed:
<!-- ##### MACRO g_rand_boolean ##### -->
<para>
Return a random #gboolean from @rand. This corresponds to a unbiased
coin toss.
</para>
@rand: a #GRand.
@Returns: a random #gboolean.
<!-- ##### FUNCTION g_rand_int ##### -->
@ -91,9 +81,12 @@ coin toss.
@rand:
@min:
@max:
@Returns:
<!-- # Unused Parameters # -->
@begin:
@end:
@Returns:
<!-- ##### FUNCTION g_rand_double ##### -->
@ -107,9 +100,12 @@ coin toss.
@rand:
@min:
@max:
@Returns:
<!-- # Unused Parameters # -->
@begin:
@end:
@Returns:
<!-- ##### FUNCTION g_random_set_seed ##### -->
@ -118,14 +114,6 @@ coin toss.
@seed:
<!-- ##### MACRO g_random_boolean ##### -->
<para>
Return a random #gboolean. This corresponds to a unbiased coin toss.
</para>
@Returns: a random #gboolean.
<!-- ##### FUNCTION g_random_int ##### -->
@ -135,9 +123,12 @@ Return a random #gboolean. This corresponds to a unbiased coin toss.
<!-- ##### FUNCTION g_random_int_range ##### -->
@min:
@max:
@Returns:
<!-- # Unused Parameters # -->
@begin:
@end:
@Returns:
<!-- ##### FUNCTION g_random_double ##### -->
@ -149,8 +140,11 @@ Return a random #gboolean. This corresponds to a unbiased coin toss.
<!-- ##### FUNCTION g_random_double_range ##### -->
@min:
@max:
@Returns:
<!-- # Unused Parameters # -->
@begin:
@end:
@Returns:

View File

@ -27,7 +27,11 @@
static inline guint
upper_power2 (guint number)
{
#ifdef DISABLE_MEM_POOLS
return number;
#else /* !DISABLE_MEM_POOLS */
return number ? 1 << g_bit_storage (number - 1) : 0;
#endif /* !DISABLE_MEM_POOLS */
}
static inline gpointer

File diff suppressed because it is too large Load Diff

View File

@ -29,35 +29,70 @@
#include <gtypes.h>
/* optionally feature DMALLOC memory allocation debugger
*/
#ifdef USE_DMALLOC
#include "dmalloc.h"
#endif
G_BEGIN_DECLS
typedef struct _GAllocator GAllocator;
typedef struct _GMemChunk GMemChunk;
typedef struct _GAllocator GAllocator;
typedef struct _GMemChunk GMemChunk;
typedef struct _GMemVTable GMemVTable;
/* Provide macros for easily allocating memory. The macros
* will cast the allocated memory to the specified type
* in order to avoid compiler warnings. (Makes the code neater).
#if GLIB_SIZEOF_VOID_P > GLIB_SIZEOF_LONG
# define G_MEM_ALIGN GLIB_SIZEOF_VOID_P
#else /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */
# define G_MEM_ALIGN GLIB_SIZEOF_LONG
#endif /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */
/* Memory allocation functions
*/
gpointer g_malloc (gulong n_bytes);
gpointer g_malloc0 (gulong n_bytes);
gpointer g_realloc (gpointer mem,
gulong n_bytes);
void g_free (gpointer mem);
gpointer g_try_malloc (gulong n_bytes);
gpointer g_try_realloc (gpointer mem,
gulong n_bytes);
#ifdef __DMALLOC_H__
# define g_new(type, count) (ALLOC (type, count))
# define g_new0(type, count) (CALLOC (type, count))
# define g_renew(type, mem, count) (REALLOC (mem, type, count))
#else /* __DMALLOC_H__ */
# define g_new(type, count) \
((type *) g_malloc ((unsigned) sizeof (type) * (count)))
# define g_new0(type, count) \
((type *) g_malloc0 ((unsigned) sizeof (type) * (count)))
# define g_renew(type, mem, count) \
((type *) g_realloc (mem, (unsigned) sizeof (type) * (count)))
#endif /* __DMALLOC_H__ */
/* Convenience memory allocators
*/
#define g_new(struct_type, n_structs) \
((struct_type *) g_malloc (((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
#define g_new0(struct_type, n_structs) \
((struct_type *) g_malloc0 (((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
#define g_renew(struct_type, mem, n_structs) \
((struct_type *) g_realloc ((mem), ((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
/* Memory allocation virtualization for debugging purposes
* g_mem_set_vtable() has to be the very first GLib function called
* if being used
*/
struct _GMemVTable
{
gpointer (*malloc) (gsize n_bytes);
gpointer (*realloc) (gpointer mem,
gsize n_bytes);
void (*free) (gpointer mem);
/* optional */
gpointer (*calloc) (gsize n_blocks,
gsize n_block_bytes);
gpointer (*try_malloc) (gsize n_bytes);
gpointer (*try_realloc) (gpointer mem,
gsize n_bytes);
};
void g_mem_set_vtable (GMemVTable *vtable);
/* Memory profiler and checker, has to be enabled via g_mem_set_vtable()
*/
extern GMemVTable *glib_mem_profiler_table;
void g_mem_profile (void);
/* Memchunk convenience functions
*/
#define g_mem_chunk_create(type, pre_alloc, alloc_type) ( \
g_mem_chunk_new (#type " mem chunks (" #pre_alloc ")", \
sizeof (type), \
@ -74,37 +109,6 @@ typedef struct _GMemChunk GMemChunk;
g_mem_chunk_free ((mem_chunk), (mem)); \
} G_STMT_END
/* Memory allocation and debugging
*/
#ifdef USE_DMALLOC
#define g_malloc(size) ((gpointer) MALLOC (size))
#define g_malloc0(size) ((gpointer) CALLOC (char, size))
#define g_realloc(mem,size) ((gpointer) REALLOC (mem, char, size))
#define g_free(mem) FREE (mem)
#else /* !USE_DMALLOC */
gpointer g_malloc (gulong size);
gpointer g_malloc0 (gulong size);
gpointer g_realloc (gpointer mem,
gulong size);
void g_free (gpointer mem);
#endif /* !USE_DMALLOC */
void g_mem_profile (void);
void g_mem_check (gpointer mem);
/* Generic allocators
*/
GAllocator* g_allocator_new (const gchar *name,
guint n_preallocs);
void g_allocator_free (GAllocator *allocator);
#define G_ALLOCATOR_LIST (1)
#define G_ALLOCATOR_SLIST (2)
#define G_ALLOCATOR_NODE (3)
/* "g_mem_chunk_new" creates a new memory chunk.
* Memory chunks are used to allocate pieces of memory which are
@ -150,9 +154,21 @@ void g_mem_chunk_info (void);
* much better name than "g_mem_chunk_clean_all" or something
* similar.
*/
void g_blow_chunks (void);
void g_blow_chunks (void);
/* Generic allocators
*/
GAllocator* g_allocator_new (const gchar *name,
guint n_preallocs);
void g_allocator_free (GAllocator *allocator);
/* internal */
#define G_ALLOCATOR_LIST (1)
#define G_ALLOCATOR_SLIST (2)
#define G_ALLOCATOR_NODE (3)
G_END_DECLS
#endif /* __G_MEM_H__ */

View File

@ -570,8 +570,8 @@ g_scanner_freeze_symbol_table (GScanner *scanner)
if (first_call)
{
g_warning("g_scanner_freeze_symbol_table and "
"g_scanner_thaw_symbol_table are deprecated.");
g_message ("g_scanner_freeze_symbol_table() and "
"g_scanner_thaw_symbol_table() are deprecated.");
first_call = FALSE;
}
#endif /* G_ENABLE_DEBUG */
@ -580,6 +580,7 @@ g_scanner_freeze_symbol_table (GScanner *scanner)
void
g_scanner_thaw_symbol_table (GScanner *scanner)
{
g_scanner_freeze_symbol_table (scanner);
}
GTokenType

View File

@ -383,9 +383,9 @@ g_basename (const gchar *file_name)
if (first_call)
{
g_warning("g_basename is deprecated. Use g_path_get_basename instead.");
g_warning("Watch out! You have to g_free the string returned by "
"g_path_get_basename.");
g_message ("g_basename is deprecated. Use g_path_get_basename instead. "
"Beware that the string returned by g_path_get_basename() has "
" to be g_free()ed.");
first_call = FALSE;
}
#endif /* G_ENABLE_DEBUG */
@ -512,7 +512,7 @@ g_dirname (const gchar *file_name)
if (first_call)
{
g_warning("g_dirname is deprecated. Use g_path_get_dirname instead.");
g_message ("g_dirname() is deprecated. Use g_path_get_dirname() instead.");
first_call = FALSE;
}
#endif /* G_ENABLE_DEBUG */

957
gmem.c

File diff suppressed because it is too large Load Diff

128
gmem.h
View File

@ -29,35 +29,70 @@
#include <gtypes.h>
/* optionally feature DMALLOC memory allocation debugger
*/
#ifdef USE_DMALLOC
#include "dmalloc.h"
#endif
G_BEGIN_DECLS
typedef struct _GAllocator GAllocator;
typedef struct _GMemChunk GMemChunk;
typedef struct _GAllocator GAllocator;
typedef struct _GMemChunk GMemChunk;
typedef struct _GMemVTable GMemVTable;
/* Provide macros for easily allocating memory. The macros
* will cast the allocated memory to the specified type
* in order to avoid compiler warnings. (Makes the code neater).
#if GLIB_SIZEOF_VOID_P > GLIB_SIZEOF_LONG
# define G_MEM_ALIGN GLIB_SIZEOF_VOID_P
#else /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */
# define G_MEM_ALIGN GLIB_SIZEOF_LONG
#endif /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */
/* Memory allocation functions
*/
gpointer g_malloc (gulong n_bytes);
gpointer g_malloc0 (gulong n_bytes);
gpointer g_realloc (gpointer mem,
gulong n_bytes);
void g_free (gpointer mem);
gpointer g_try_malloc (gulong n_bytes);
gpointer g_try_realloc (gpointer mem,
gulong n_bytes);
#ifdef __DMALLOC_H__
# define g_new(type, count) (ALLOC (type, count))
# define g_new0(type, count) (CALLOC (type, count))
# define g_renew(type, mem, count) (REALLOC (mem, type, count))
#else /* __DMALLOC_H__ */
# define g_new(type, count) \
((type *) g_malloc ((unsigned) sizeof (type) * (count)))
# define g_new0(type, count) \
((type *) g_malloc0 ((unsigned) sizeof (type) * (count)))
# define g_renew(type, mem, count) \
((type *) g_realloc (mem, (unsigned) sizeof (type) * (count)))
#endif /* __DMALLOC_H__ */
/* Convenience memory allocators
*/
#define g_new(struct_type, n_structs) \
((struct_type *) g_malloc (((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
#define g_new0(struct_type, n_structs) \
((struct_type *) g_malloc0 (((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
#define g_renew(struct_type, mem, n_structs) \
((struct_type *) g_realloc ((mem), ((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
/* Memory allocation virtualization for debugging purposes
* g_mem_set_vtable() has to be the very first GLib function called
* if being used
*/
struct _GMemVTable
{
gpointer (*malloc) (gsize n_bytes);
gpointer (*realloc) (gpointer mem,
gsize n_bytes);
void (*free) (gpointer mem);
/* optional */
gpointer (*calloc) (gsize n_blocks,
gsize n_block_bytes);
gpointer (*try_malloc) (gsize n_bytes);
gpointer (*try_realloc) (gpointer mem,
gsize n_bytes);
};
void g_mem_set_vtable (GMemVTable *vtable);
/* Memory profiler and checker, has to be enabled via g_mem_set_vtable()
*/
extern GMemVTable *glib_mem_profiler_table;
void g_mem_profile (void);
/* Memchunk convenience functions
*/
#define g_mem_chunk_create(type, pre_alloc, alloc_type) ( \
g_mem_chunk_new (#type " mem chunks (" #pre_alloc ")", \
sizeof (type), \
@ -74,37 +109,6 @@ typedef struct _GMemChunk GMemChunk;
g_mem_chunk_free ((mem_chunk), (mem)); \
} G_STMT_END
/* Memory allocation and debugging
*/
#ifdef USE_DMALLOC
#define g_malloc(size) ((gpointer) MALLOC (size))
#define g_malloc0(size) ((gpointer) CALLOC (char, size))
#define g_realloc(mem,size) ((gpointer) REALLOC (mem, char, size))
#define g_free(mem) FREE (mem)
#else /* !USE_DMALLOC */
gpointer g_malloc (gulong size);
gpointer g_malloc0 (gulong size);
gpointer g_realloc (gpointer mem,
gulong size);
void g_free (gpointer mem);
#endif /* !USE_DMALLOC */
void g_mem_profile (void);
void g_mem_check (gpointer mem);
/* Generic allocators
*/
GAllocator* g_allocator_new (const gchar *name,
guint n_preallocs);
void g_allocator_free (GAllocator *allocator);
#define G_ALLOCATOR_LIST (1)
#define G_ALLOCATOR_SLIST (2)
#define G_ALLOCATOR_NODE (3)
/* "g_mem_chunk_new" creates a new memory chunk.
* Memory chunks are used to allocate pieces of memory which are
@ -150,9 +154,21 @@ void g_mem_chunk_info (void);
* much better name than "g_mem_chunk_clean_all" or something
* similar.
*/
void g_blow_chunks (void);
void g_blow_chunks (void);
/* Generic allocators
*/
GAllocator* g_allocator_new (const gchar *name,
guint n_preallocs);
void g_allocator_free (GAllocator *allocator);
/* internal */
#define G_ALLOCATOR_LIST (1)
#define G_ALLOCATOR_SLIST (2)
#define G_ALLOCATOR_NODE (3)
G_END_DECLS
#endif /* __G_MEM_H__ */

View File

@ -1,3 +1,17 @@
Thu Dec 28 11:36:44 2000 Tim Janik <timj@gtk.org>
* gbsearcharray.c (upper_power2): disable G_BSEARCH_ALIGN_POWER2
fucntionality if DISABLE_MEM_POOLS is defined.
* gtype.c: honour DISABLE_MEM_POOLS.
* gsignal.c (g_signal_init): flag signal key bsearch array with
G_BSEARCH_ALIGN_POWER2 to avoid excessive growth time. honour
DISABLE_MEM_POOLS.
* gparam.h: added G_PARAM_READWRITE alias for (G_PARAM_READABLE |
G_PARAM_WRITABLE).
2000-12-15 Tor Lillqvist <tml@iki.fi>
* gobject.def: Update.

View File

@ -27,7 +27,11 @@
static inline guint
upper_power2 (guint number)
{
#ifdef DISABLE_MEM_POOLS
return number;
#else /* !DISABLE_MEM_POOLS */
return number ? 1 << g_bit_storage (number - 1) : 0;
#endif /* !DISABLE_MEM_POOLS */
}
static inline gpointer

View File

@ -27,7 +27,6 @@
#define PREALLOC_CPARAMS (8)
#define DEBUG_OBJECTS
/* --- macros --- */
@ -126,22 +125,21 @@ struct _NotifyQueue
/* --- variables --- */
static GQuark quark_notify_queue = 0;
static GQuark quark_property_id = 0;
static GQuark quark_closure_array = 0;
static GParamSpecPool *pspec_pool = NULL;
static gulong gobject_signals[LAST_SIGNAL] = { 0, };
static GQuark quark_notify_queue = 0;
static GQuark quark_property_id = 0;
static GQuark quark_closure_array = 0;
static GParamSpecPool *pspec_pool = NULL;
static gulong gobject_signals[LAST_SIGNAL] = { 0, };
/* --- functions --- */
#ifdef DEBUG_OBJECTS
#ifdef G_ENABLE_DEBUG
/* We need an actual method for handling debug keys in GLib.
* For now, we'll simply use, as a method
* 'extern gboolean glib_debug_objects'
*/
static volatile GObject *glib_trap_object_ref = NULL;
gboolean glib_debug_objects = FALSE;
static guint debug_objects_count = 0;
static GHashTable *debug_objects_ht = NULL;
static void
@ -168,7 +166,7 @@ debug_objects_atexit (void)
}
}
}
#endif /* DEBUG_OBJECTS */
#endif /* G_ENABLE_DEBUG */
void
g_object_type_init (void) /* sync with gtype.c */
@ -210,9 +208,9 @@ g_object_type_init (void) /* sync with gtype.c */
type = g_type_register_fundamental (G_TYPE_OBJECT, "GObject", &info, &finfo, 0);
g_assert (type == G_TYPE_OBJECT);
#ifdef DEBUG_OBJECTS
#ifdef G_ENABLE_DEBUG
g_atexit (debug_objects_atexit);
#endif /* DEBUG_OBJECTS */
#endif /* G_ENABLE_DEBUG */
}
static void
@ -433,7 +431,7 @@ g_object_init (GObject *object)
/* freeze object's notification queue, g_object_new_valist() takes care of that */
object_freeze_notifies (object);
#ifdef DEBUG_OBJECTS
#ifdef G_ENABLE_DEBUG
if (glib_debug_objects)
{
if (!debug_objects_ht)
@ -441,7 +439,7 @@ g_object_init (GObject *object)
debug_objects_count++;
g_hash_table_insert (debug_objects_ht, object, object);
}
#endif /* DEBUG_OBJECTS */
#endif /* G_ENABLE_DEBUG */
}
static void
@ -512,15 +510,20 @@ g_object_last_unref (GObject *object)
if (object->ref_count == 1) /* may have been re-referenced meanwhile */
G_OBJECT_GET_CLASS (object)->shutdown (object);
#ifdef G_ENABLE_DEBUG
if (glib_trap_object_ref == object)
G_BREAKPOINT ();
#endif /* G_ENABLE_DEBUG */
object->ref_count -= 1;
if (object->ref_count == 0) /* may have been re-referenced meanwhile */
{
G_OBJECT_GET_CLASS (object)->finalize (object);
#ifdef DEBUG_OBJECTS
#ifdef G_ENABLE_DEBUG
if (glib_debug_objects && debug_objects_ht)
g_assert (g_hash_table_lookup (debug_objects_ht, object) == NULL);
#endif /* DEBUG_OBJECTS */
#endif /* G_ENABLE_DEBUG */
g_type_free_instance ((GTypeInstance*) object);
}
}
@ -540,7 +543,7 @@ g_object_finalize (GObject *object)
g_signal_handlers_destroy (object);
g_datalist_clear (&object->qdata);
#ifdef DEBUG_OBJECTS
#ifdef G_ENABLE_DEBUG
if (glib_debug_objects)
{
g_assert (g_hash_table_lookup (debug_objects_ht, object) == object);
@ -548,7 +551,7 @@ g_object_finalize (GObject *object)
g_hash_table_remove (debug_objects_ht, object);
debug_objects_count--;
}
#endif /* DEBUG_OBJECTS */
#endif /* G_ENABLE_DEBUG */
}
static inline void
@ -1224,6 +1227,11 @@ g_object_ref (gpointer _object)
g_return_val_if_fail (G_IS_OBJECT (object), NULL);
g_return_val_if_fail (object->ref_count > 0, NULL);
#ifdef G_ENABLE_DEBUG
if (glib_trap_object_ref == object)
G_BREAKPOINT ();
#endif /* G_ENABLE_DEBUG */
object->ref_count += 1;
return object;
@ -1237,6 +1245,11 @@ g_object_unref (gpointer _object)
g_return_if_fail (G_IS_OBJECT (object));
g_return_if_fail (object->ref_count > 0);
#ifdef G_ENABLE_DEBUG
if (glib_trap_object_ref == object)
G_BREAKPOINT ();
#endif /* G_ENABLE_DEBUG */
if (object->ref_count > 1)
object->ref_count -= 1;
else

View File

@ -53,6 +53,7 @@ typedef enum
/* bits in the range 0xffffff00 are reserved for 3rd party usage */
#define G_PARAM_USER_MASK (0xffffff00)
} GParamFlags;
#define G_PARAM_READWRITE (G_PARAM_READABLE | G_PARAM_WRITABLE)
/* --- typedefs & structures --- */

View File

@ -33,15 +33,14 @@
#define HANDLER_PRE_ALLOC (48)
#define EMISSION_PRE_ALLOC (16)
#define TIGHT_MEMORY (1)
#define REPORT_BUG "please report occourance circumstances to gtk-devel-list@gnome.org"
/* --- generic allocation --- */
/* we can special case allocations generically by replacing
/* we special case allocations generically by replacing
* these functions with more speed/memory aware variants
*/
#ifndef DISABLE_MEM_POOLS
static inline gpointer
g_generic_node_alloc (GTrashStack **trash_stack_p,
guint sizeof_node,
@ -71,6 +70,21 @@ g_generic_node_free (GTrashStack **trash_stack_p,
{
g_trash_stack_push (trash_stack_p, node);
}
#else /* !DISABLE_MEM_POOLS */
static inline gpointer
g_generic_node_alloc (GTrashStack **trash_stack_p,
guint sizeof_node,
guint nodes_pre_alloc)
{
return g_malloc (sizeof_node);
}
static inline void
g_generic_node_free (GTrashStack **trash_stack_p,
gpointer node)
{
g_free (node);
}
#endif /* !DISABLE_MEM_POOLS */
/* --- typedefs --- */
@ -640,7 +654,7 @@ g_signal_init (void) /* sync with gtype.c */
/* setup signal key array */
g_signal_key_bsa.cmp_func = signal_key_cmp;
g_signal_key_bsa.sizeof_node = sizeof (SignalKey);
g_signal_key_bsa.flags = 0; /* alloc-only */
g_signal_key_bsa.flags = G_BSEARCH_ALIGN_POWER2; /* alloc-only */
/* setup handler list binary searchable array hash table (in german, that'd be one word ;) */
g_handler_list_bsa_ht = g_hash_table_new (g_direct_hash, NULL);
@ -1066,7 +1080,7 @@ signal_destroy_R (SignalNode *signal_node)
signal_node->c_marshaller = NULL;
signal_node->emission_hooks = NULL;
#ifndef G_DISABLE_CHECKS
#ifdef G_ENABLE_DEBUG
/* check current emissions */
{
Emission *emission;
@ -1539,7 +1553,7 @@ g_signal_emitv (const GValue *instance_and_params,
G_UNLOCK (g_signal_mutex);
return;
}
#ifndef G_DISABLE_CHECKS
#ifdef G_ENABLE_DEBUG
if (detail && !(node->flags & G_SIGNAL_DETAILED))
{
g_warning ("%s: signal id `%u' does not support detail (%u)", G_STRLOC, signal_id, detail);
@ -1582,7 +1596,7 @@ g_signal_emitv (const GValue *instance_and_params,
}
else
return_value = NULL;
#endif /* !G_DISABLE_CHECKS */
#endif /* G_ENABLE_DEBUG */
signal_emit_R (node, detail, instance, return_value, instance_and_params);
G_UNLOCK (g_signal_mutex);

View File

@ -21,7 +21,6 @@
#include "gtypeplugin.h"
#include <string.h>
#undef FIXME_DISABLE_PREALLOCATIONS
/* NOTE: some functions (some internal variants and exported ones)
* invalidate data portions of the TypeNodes. if external functions/callbacks
@ -753,10 +752,11 @@ type_data_make (TypeNode *node,
data->instance.class_data = info->class_data;
data->instance.class = NULL;
data->instance.instance_size = info->instance_size;
data->instance.n_preallocs = MIN (info->n_preallocs, 1024);
#ifdef FIXME_DISABLE_PREALLOCATIONS
#ifdef DISABLE_MEM_POOLS
data->instance.n_preallocs = 0;
#endif
#else /* !DISABLE_MEM_POOLS */
data->instance.n_preallocs = MIN (info->n_preallocs, 1024);
#endif /* !DISABLE_MEM_POOLS */
data->instance.instance_init = info->instance_init;
data->instance.mem_chunk = NULL;
}

View File

@ -570,8 +570,8 @@ g_scanner_freeze_symbol_table (GScanner *scanner)
if (first_call)
{
g_warning("g_scanner_freeze_symbol_table and "
"g_scanner_thaw_symbol_table are deprecated.");
g_message ("g_scanner_freeze_symbol_table() and "
"g_scanner_thaw_symbol_table() are deprecated.");
first_call = FALSE;
}
#endif /* G_ENABLE_DEBUG */
@ -580,6 +580,7 @@ g_scanner_freeze_symbol_table (GScanner *scanner)
void
g_scanner_thaw_symbol_table (GScanner *scanner)
{
g_scanner_freeze_symbol_table (scanner);
}
GTokenType

View File

@ -383,9 +383,9 @@ g_basename (const gchar *file_name)
if (first_call)
{
g_warning("g_basename is deprecated. Use g_path_get_basename instead.");
g_warning("Watch out! You have to g_free the string returned by "
"g_path_get_basename.");
g_message ("g_basename is deprecated. Use g_path_get_basename instead. "
"Beware that the string returned by g_path_get_basename() has "
" to be g_free()ed.");
first_call = FALSE;
}
#endif /* G_ENABLE_DEBUG */
@ -512,7 +512,7 @@ g_dirname (const gchar *file_name)
if (first_call)
{
g_warning("g_dirname is deprecated. Use g_path_get_dirname instead.");
g_message ("g_dirname() is deprecated. Use g_path_get_dirname() instead.");
first_call = FALSE;
}
#endif /* G_ENABLE_DEBUG */