diff options
author | Elliot Lee <sopwith@cuc.ml.org> | 1998-11-30 19:07:15 +0000 |
---|---|---|
committer | Elliot Lee <sopwith@src.gnome.org> | 1998-11-30 19:07:15 +0000 |
commit | 060978e069b3c1726c7a1fb3916c3e8c8348a813 (patch) | |
tree | b92907dd3d6ca58cb5e5bf7e7481277feada033c /gdk | |
parent | 58ca2448eb7d0a337fd83bd2951f5d9adde81b7c (diff) | |
download | gdk-pixbuf-060978e069b3c1726c7a1fb3916c3e8c8348a813.tar.gz |
I submitted this patch twice to gtk-devel-list, and received no comments,
I submitted this patch twice to gtk-devel-list, and received no comments, so
am committing it. Although not exhaustively tested, I have been using this
gtk+ for a week w/o problems, and I did read the code to ensure that nothing
ever writes to these data structures. If by chance people encounter SEGV's in
gtk+ code that is setting values in global data structures, this patch could
be a possible culprit.
1998-11-30 Elliot Lee <sopwith@cuc.ml.org>
* {gdk,gtk}/*.c: Make read-only data structures "static const" to
allow them to be shared, mainly including (but not limited to) the
GtkTypeInfo structures for each class.
* gtk/gtkfilesel.c: Add /net to the "leave me alone" directory listing.
Diffstat (limited to 'gdk')
-rw-r--r-- | gdk/gdk.c | 6 | ||||
-rw-r--r-- | gdk/gdkinput.c | 4 | ||||
-rw-r--r-- | gdk/gdkrgb.c | 10 | ||||
-rw-r--r-- | gdk/gdkvisual.c | 10 | ||||
-rw-r--r-- | gdk/gdkwindow.c | 4 | ||||
-rw-r--r-- | gdk/x11/gdkinput.c | 4 | ||||
-rw-r--r-- | gdk/x11/gdkmain-x11.c | 6 | ||||
-rw-r--r-- | gdk/x11/gdkvisual-x11.c | 10 | ||||
-rw-r--r-- | gdk/x11/gdkwindow-x11.c | 4 |
9 files changed, 29 insertions, 29 deletions
@@ -229,7 +229,7 @@ static gulong base_id; static gint autorepeat; #ifdef G_ENABLE_DEBUG -static GDebugKey gdk_debug_keys[] = { +static const GDebugKey gdk_debug_keys[] = { {"events", GDK_DEBUG_EVENTS}, {"misc", GDK_DEBUG_MISC}, {"dnd", GDK_DEBUG_DND}, @@ -1504,8 +1504,8 @@ gdk_pointer_grab (GdkWindow * window, guint32 time) { /* From gdkwindow.c */ - extern int nevent_masks; - extern int event_mask_table[]; + extern const int nevent_masks; + extern const int event_mask_table[]; gint return_val; GdkWindowPrivate *window_private; diff --git a/gdk/gdkinput.c b/gdk/gdkinput.c index c0f199fae..a11da09f2 100644 --- a/gdk/gdkinput.c +++ b/gdk/gdkinput.c @@ -38,9 +38,9 @@ static GdkDevicePrivate *gdk_input_find_device (guint32 id); /* Incorporate the specific routines depending on compilation options */ -static GdkAxisUse gdk_input_core_axes[] = { GDK_AXIS_X, GDK_AXIS_Y }; +static const GdkAxisUse gdk_input_core_axes[] = { GDK_AXIS_X, GDK_AXIS_Y }; -static GdkDeviceInfo gdk_input_core_info = +static const GdkDeviceInfo gdk_input_core_info = { GDK_CORE_POINTER, "Core Pointer", diff --git a/gdk/gdkrgb.c b/gdk/gdkrgb.c index ad124457a..818b29f3d 100644 --- a/gdk/gdkrgb.c +++ b/gdk/gdkrgb.c @@ -304,7 +304,7 @@ gdk_rgb_try_colormap (gint nr, gint ng, gint nb) static gboolean gdk_rgb_do_colormaps (void) { - const gint sizes[][3] = { + static const gint sizes[][3] = { /* { 6, 7, 6 }, */ { 6, 6, 6 }, { 6, 6, 5 }, @@ -316,7 +316,7 @@ gdk_rgb_do_colormaps (void) { 3, 3, 3 }, { 2, 2, 2 } }; - const gint n_sizes = sizeof(sizes) / (3 * sizeof(gint)); + static const gint n_sizes = sizeof(sizes) / (3 * sizeof(gint)); gint i; for (i = 0; i < n_sizes; i++) @@ -387,7 +387,7 @@ static guint32 gdk_rgb_score_visual (GdkVisual *visual) { guint32 quality, speed, sys, pseudo; - gchar* visual_names[] = + static const gchar* visual_names[] = { "static gray", "grayscale", @@ -535,7 +535,7 @@ void gdk_rgb_init (void) { gint i; - gint byte_order[1] = { 1 }; + static const gint byte_order[1] = { 1 }; /* check endian sanity */ #if G_BYTE_ORDER == G_BIG_ENDIAN @@ -982,7 +982,7 @@ static const guchar DM[128][128] = #define DM_WIDTH 8 #define DM_WIDTH_SHIFT 3 #define DM_HEIGHT 8 -static guchar DM[8][8] = +static const guchar DM[8][8] = { { 0, 32, 8, 40, 2, 34, 10, 42 }, { 48, 16, 56, 24, 50, 18, 58, 26 }, diff --git a/gdk/gdkvisual.c b/gdk/gdkvisual.c index 693020ef6..ebdcccb12 100644 --- a/gdk/gdkvisual.c +++ b/gdk/gdkvisual.c @@ -44,7 +44,7 @@ static gint navailable_types; #ifdef G_ENABLE_DEBUG -static gchar* visual_names[] = +static const gchar* visual_names[] = { "static gray", "grayscale", @@ -61,8 +61,8 @@ static GHashTable *visual_hash = NULL; void gdk_visual_init (void) { - static gint possible_depths[7] = { 32, 24, 16, 15, 8, 4, 1 }; - static GdkVisualType possible_types[6] = + static const gint possible_depths[7] = { 32, 24, 16, 15, 8, 4, 1 }; + static const GdkVisualType possible_types[6] = { GDK_VISUAL_DIRECT_COLOR, GDK_VISUAL_TRUE_COLOR, @@ -72,8 +72,8 @@ gdk_visual_init (void) GDK_VISUAL_STATIC_GRAY }; - static gint npossible_depths = 7; - static gint npossible_types = 6; + static const gint npossible_depths = sizeof(possible_depths)/sizeof(gint); + static const gint npossible_types = sizeof(possible_types)/sizeof(GdkVisualType); XVisualInfo *visual_list; XVisualInfo visual_template; diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 09399dcf1..c8a42595e 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -33,8 +33,7 @@ #include <X11/extensions/shape.h> #endif -int nevent_masks = 20; -int event_mask_table[20] = +const int event_mask_table[20] = { ExposureMask, PointerMotionMask, @@ -57,6 +56,7 @@ int event_mask_table[20] = 0, /* PROXIMTY_OUT */ SubstructureNotifyMask }; +const int nevent_masks = sizeof(event_mask_table)/sizeof(int); static gboolean gdk_window_have_shape_ext (void); diff --git a/gdk/x11/gdkinput.c b/gdk/x11/gdkinput.c index c0f199fae..a11da09f2 100644 --- a/gdk/x11/gdkinput.c +++ b/gdk/x11/gdkinput.c @@ -38,9 +38,9 @@ static GdkDevicePrivate *gdk_input_find_device (guint32 id); /* Incorporate the specific routines depending on compilation options */ -static GdkAxisUse gdk_input_core_axes[] = { GDK_AXIS_X, GDK_AXIS_Y }; +static const GdkAxisUse gdk_input_core_axes[] = { GDK_AXIS_X, GDK_AXIS_Y }; -static GdkDeviceInfo gdk_input_core_info = +static const GdkDeviceInfo gdk_input_core_info = { GDK_CORE_POINTER, "Core Pointer", diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c index 36e0fb143..f504ea313 100644 --- a/gdk/x11/gdkmain-x11.c +++ b/gdk/x11/gdkmain-x11.c @@ -229,7 +229,7 @@ static gulong base_id; static gint autorepeat; #ifdef G_ENABLE_DEBUG -static GDebugKey gdk_debug_keys[] = { +static const GDebugKey gdk_debug_keys[] = { {"events", GDK_DEBUG_EVENTS}, {"misc", GDK_DEBUG_MISC}, {"dnd", GDK_DEBUG_DND}, @@ -1504,8 +1504,8 @@ gdk_pointer_grab (GdkWindow * window, guint32 time) { /* From gdkwindow.c */ - extern int nevent_masks; - extern int event_mask_table[]; + extern const int nevent_masks; + extern const int event_mask_table[]; gint return_val; GdkWindowPrivate *window_private; diff --git a/gdk/x11/gdkvisual-x11.c b/gdk/x11/gdkvisual-x11.c index 693020ef6..ebdcccb12 100644 --- a/gdk/x11/gdkvisual-x11.c +++ b/gdk/x11/gdkvisual-x11.c @@ -44,7 +44,7 @@ static gint navailable_types; #ifdef G_ENABLE_DEBUG -static gchar* visual_names[] = +static const gchar* visual_names[] = { "static gray", "grayscale", @@ -61,8 +61,8 @@ static GHashTable *visual_hash = NULL; void gdk_visual_init (void) { - static gint possible_depths[7] = { 32, 24, 16, 15, 8, 4, 1 }; - static GdkVisualType possible_types[6] = + static const gint possible_depths[7] = { 32, 24, 16, 15, 8, 4, 1 }; + static const GdkVisualType possible_types[6] = { GDK_VISUAL_DIRECT_COLOR, GDK_VISUAL_TRUE_COLOR, @@ -72,8 +72,8 @@ gdk_visual_init (void) GDK_VISUAL_STATIC_GRAY }; - static gint npossible_depths = 7; - static gint npossible_types = 6; + static const gint npossible_depths = sizeof(possible_depths)/sizeof(gint); + static const gint npossible_types = sizeof(possible_types)/sizeof(GdkVisualType); XVisualInfo *visual_list; XVisualInfo visual_template; diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 09399dcf1..c8a42595e 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -33,8 +33,7 @@ #include <X11/extensions/shape.h> #endif -int nevent_masks = 20; -int event_mask_table[20] = +const int event_mask_table[20] = { ExposureMask, PointerMotionMask, @@ -57,6 +56,7 @@ int event_mask_table[20] = 0, /* PROXIMTY_OUT */ SubstructureNotifyMask }; +const int nevent_masks = sizeof(event_mask_table)/sizeof(int); static gboolean gdk_window_have_shape_ext (void); |