Mercurial > pidgin
changeset 21015:787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
the amount of writable memory
+08108000 12K rwx-- /local/local/bin/pidgin
-08107000 16K rwx-- /local/local/bin/pidgin
+005bf000 20K rwx-- /local/local/lib/libpurple.so.0.2.1
-005be000 24K rwx-- /local/local/lib/libpurple.so.0.2.1
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Fri, 26 Oct 2007 04:59:23 +0000 |
parents | 0314cb293463 |
children | abd768f06e7b aed039f5360b |
files | libpurple/cipher.c libpurple/protocols/jabber/buddy.c libpurple/protocols/jabber/usermood.c libpurple/protocols/oscar/oscar.c libpurple/proxy.c libpurple/util.c pidgin/gtkcertmgr.c pidgin/gtkdebug.c pidgin/gtkdialogs.c pidgin/gtkimhtml.c pidgin/gtkmain.c pidgin/gtknickcolors.h pidgin/gtkprefs.c pidgin/gtkprivacy.c pidgin/gtksound.c |
diffstat | 15 files changed, 45 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/cipher.c Fri Oct 26 00:13:18 2007 +0000 +++ b/libpurple/cipher.c Fri Oct 26 04:59:23 2007 +0000 @@ -616,7 +616,7 @@ /* * The s-box values are permuted according to the 'primitive function P' */ -static guint32 sbox1[64] = +static const guint32 sbox1[64] = { 0x00808200, 0x00000000, 0x00008000, 0x00808202, 0x00808002, 0x00008202, 0x00000002, 0x00008000, 0x00000200, 0x00808200, 0x00808202, 0x00000200, 0x00800202, 0x00808002, 0x00800000, 0x00000002, @@ -628,7 +628,7 @@ 0x00000202, 0x00800200, 0x00800200, 0x00000000, 0x00008002, 0x00008200, 0x00000000, 0x00808002 }; -static guint32 sbox2[64] = +static const guint32 sbox2[64] = { 0x40084010, 0x40004000, 0x00004000, 0x00084010, 0x00080000, 0x00000010, 0x40080010, 0x40004010, 0x40000010, 0x40084010, 0x40084000, 0x40000000, 0x40004000, 0x00080000, 0x00000010, 0x40080010, @@ -640,7 +640,7 @@ 0x00084000, 0x00000000, 0x40004000, 0x00004010, 0x40000000, 0x40080010, 0x40084010, 0x00084000 }; -static guint32 sbox3[64] = +static const guint32 sbox3[64] = { 0x00000104, 0x04010100, 0x00000000, 0x04010004, 0x04000100, 0x00000000, 0x00010104, 0x04000100, 0x00010004, 0x04000004, 0x04000004, 0x00010000, 0x04010104, 0x00010004, 0x04010000, 0x00000104, @@ -652,7 +652,7 @@ 0x04010000, 0x04000104, 0x00000104, 0x04010000, 0x00010104, 0x00000004, 0x04010004, 0x00010100 }; -static guint32 sbox4[64] = +static const guint32 sbox4[64] = { 0x80401000, 0x80001040, 0x80001040, 0x00000040, 0x00401040, 0x80400040, 0x80400000, 0x80001000, 0x00000000, 0x00401000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00400040, 0x80400000, @@ -664,7 +664,7 @@ 0x80001000, 0x00001040, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x00001000, 0x00401040 }; -static guint32 sbox5[64] = +static const guint32 sbox5[64] = { 0x00000080, 0x01040080, 0x01040000, 0x21000080, 0x00040000, 0x00000080, 0x20000000, 0x01040000, 0x20040080, 0x00040000, 0x01000080, 0x20040080, 0x21000080, 0x21040000, 0x00040080, 0x20000000, @@ -676,7 +676,7 @@ 0x00040080, 0x01000080, 0x20000080, 0x00040000, 0x00000000, 0x20040000, 0x01040080, 0x20000080 }; -static guint32 sbox6[64] = +static const guint32 sbox6[64] = { 0x10000008, 0x10200000, 0x00002000, 0x10202008, 0x10200000, 0x00000008, 0x10202008, 0x00200000, 0x10002000, 0x00202008, 0x00200000, 0x10000008, 0x00200008, 0x10002000, 0x10000000, 0x00002008, @@ -688,7 +688,7 @@ 0x00002000, 0x00200008, 0x10002008, 0x00000000, 0x10202000, 0x10000000, 0x00200008, 0x10002008 }; -static guint32 sbox7[64] = +static const guint32 sbox7[64] = { 0x00100000, 0x02100001, 0x02000401, 0x00000000, 0x00000400, 0x02000401, 0x00100401, 0x02100400, 0x02100401, 0x00100000, 0x00000000, 0x02000001, 0x00000001, 0x02000000, 0x02100001, 0x00000401, @@ -700,7 +700,7 @@ 0x00000000, 0x00100401, 0x02100000, 0x00000400, 0x02000001, 0x02000400, 0x00000400, 0x00100001 }; -static guint32 sbox8[64] = +static const guint32 sbox8[64] = { 0x08000820, 0x00000800, 0x00020000, 0x08020820, 0x08000000, 0x08000820, 0x00000020, 0x08000000, 0x00020020, 0x08020000, 0x08020820, 0x00020800, 0x08020800, 0x00020820, 0x00000800, 0x00000020, @@ -718,7 +718,7 @@ * * These two tables are part of the 'permuted choice 1' function. * * In this implementation several speed improvements are done. * */ -static guint32 leftkey_swap[16] = +static const guint32 leftkey_swap[16] = { 0x00000000, 0x00000001, 0x00000100, 0x00000101, 0x00010000, 0x00010001, 0x00010100, 0x00010101, @@ -726,7 +726,7 @@ 0x01010000, 0x01010001, 0x01010100, 0x01010101 }; -static guint32 rightkey_swap[16] = +static const guint32 rightkey_swap[16] = { 0x00000000, 0x01000000, 0x00010000, 0x01010000, 0x00000100, 0x01000100, 0x00010100, 0x01010100, @@ -742,7 +742,7 @@ * ordering of the subkeys so we can omit the table for decryption * subkey schedule. */ -static guint8 encrypt_rotate_tab[16] = +static const guint8 encrypt_rotate_tab[16] = { 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 };
--- a/libpurple/protocols/jabber/buddy.c Fri Oct 26 00:13:18 2007 +0000 +++ b/libpurple/protocols/jabber/buddy.c Fri Oct 26 04:59:23 2007 +0000 @@ -279,7 +279,7 @@ char *tag; /* tag text */ char *ptag; /* parent tag "path" text */ char *url; /* vCard display format if URL */ -} vcard_template_data[] = { +} const vcard_template_data[] = { {N_("Full Name"), NULL, TRUE, TRUE, "FN", NULL, NULL}, {N_("Family Name"), NULL, TRUE, TRUE, "FAMILY", "N", NULL}, {N_("Given Name"), NULL, TRUE, TRUE, "GIVEN", "N", NULL}, @@ -311,7 +311,7 @@ struct tag_attr { char *attr; char *value; -} vcard_tag_attr_list[] = { +} const vcard_tag_attr_list[] = { {"prodid", "-//HandGen//NONSGML vGen v1.0//EN"}, {"version", "2.0", }, {"xmlns", "vcard-temp", }, @@ -337,7 +337,7 @@ * from the vCard template struct. */ if(parent_tag == NULL) { - struct vcard_template *vc_tp = vcard_template_data; + const struct vcard_template *vc_tp = vcard_template_data; while(vc_tp->label != NULL) { if(strcmp(vc_tp->tag, new_tag) == 0) { @@ -395,7 +395,7 @@ JabberIq *iq; JabberStream *js = gc->proto_data; xmlnode *vc_node; - struct tag_attr *tag_attr; + const struct tag_attr *tag_attr; /* if we have't grabbed the remote vcard yet, we can't * assume that what we have here is correct */ @@ -614,7 +614,7 @@ const char *text; char *p; const struct vcard_template *vc_tp; - struct tag_attr *tag_attr; + const struct tag_attr *tag_attr; vc_node = xmlnode_new("vCard");
--- a/libpurple/protocols/jabber/usermood.c Fri Oct 26 00:13:18 2007 +0000 +++ b/libpurple/protocols/jabber/usermood.c Fri Oct 26 04:59:23 2007 +0000 @@ -28,7 +28,7 @@ #include "request.h" #include "debug.h" -static const char *moodstrings[] = { +static const char * const moodstrings[] = { "afraid", "amazed", "angry",
--- a/libpurple/protocols/oscar/oscar.c Fri Oct 26 00:13:18 2007 +0000 +++ b/libpurple/protocols/oscar/oscar.c Fri Oct 26 04:59:23 2007 +0000 @@ -112,7 +112,7 @@ gchar *nick; }; -static char *msgerrreason[] = { +static const char * const msgerrreason[] = { N_("Invalid error"), N_("Invalid SNAC"), N_("Rate to host"), @@ -139,7 +139,7 @@ N_("Queue full"), N_("Not while on AOL") }; -static int msgerrreasonlen = 25; +static const int msgerrreasonlen = G_N_ELEMENTS(msgerrreason); /* All the libfaim->purple callback functions */ static int purple_parse_auth_resp (OscarData *, FlapConnection *, FlapFrame *, ...);
--- a/libpurple/proxy.c Fri Oct 26 00:13:18 2007 +0000 +++ b/libpurple/proxy.c Fri Oct 26 04:59:23 2007 +0000 @@ -70,7 +70,7 @@ gsize read_len; }; -static const char *socks5errors[] = { +static const char * const socks5errors[] = { "succeeded\n", "general SOCKS server failure\n", "connection not allowed by ruleset\n",
--- a/libpurple/util.c Fri Oct 26 00:13:18 2007 +0000 +++ b/libpurple/util.c Fri Oct 26 04:59:23 2007 +0000 @@ -3199,7 +3199,7 @@ char * purple_str_size_to_units(size_t size) { - static const char *size_str[4] = { "bytes", "KiB", "MiB", "GiB" }; + static const char * const size_str[] = { "bytes", "KiB", "MiB", "GiB" }; float size_mag; int size_index = 0; @@ -3392,11 +3392,11 @@ char host[256], path[256], user[256], passwd[256]; int port = 0; /* hyphen at end includes it in control set */ - static char addr_ctrl[] = "A-Za-z0-9.-"; - static char port_ctrl[] = "0-9"; - static char page_ctrl[] = "A-Za-z0-9.~_/:*!@&%%?=+^-"; - static char user_ctrl[] = "A-Za-z0-9.~_/*!&%%?=+^-"; - static char passwd_ctrl[] = "A-Za-z0-9.~_/*!&%%?=+^-"; + static const char addr_ctrl[] = "A-Za-z0-9.-"; + static const char port_ctrl[] = "0-9"; + static const char page_ctrl[] = "A-Za-z0-9.~_/:*!@&%%?=+^-"; + static const char user_ctrl[] = "A-Za-z0-9.~_/*!&%%?=+^-"; + static const char passwd_ctrl[] = "A-Za-z0-9.~_/*!&%%?=+^-"; g_return_val_if_fail(url != NULL, FALSE);
--- a/pidgin/gtkcertmgr.c Fri Oct 26 00:13:18 2007 +0000 +++ b/pidgin/gtkcertmgr.c Fri Oct 26 04:59:23 2007 +0000 @@ -525,7 +525,7 @@ return mgmt_widget; } -PidginCertificateManager tls_peers_mgmt = { +const PidginCertificateManager tls_peers_mgmt = { tls_peers_mgmt_build, /* Widget creation function */ N_("SSL Servers") };
--- a/pidgin/gtkdebug.c Fri Oct 26 00:13:18 2007 +0000 +++ b/pidgin/gtkdebug.c Fri Oct 26 04:59:23 2007 +0000 @@ -68,7 +68,7 @@ GtkWidget *filterlevel; } DebugWindow; -static char debug_fg_colors[][8] = { +static const char debug_fg_colors[][8] = { "#000000", /**< All debug levels. */ "#666666", /**< Misc. */ "#000000", /**< Information. */
--- a/pidgin/gtkdialogs.c Fri Oct 26 00:13:18 2007 +0000 +++ b/pidgin/gtkdialogs.c Fri Oct 26 04:59:23 2007 +0000 @@ -68,7 +68,7 @@ }; /* Order: Lead Developer, then Alphabetical by Last Name */ -static struct developer developers[] = { +static const struct developer developers[] = { {"Sean Egan", N_("lead developer"), "sean.egan@gmail.com"}, {"Daniel 'datallah' Atallah", N_("developer"), NULL}, {"Ethan 'Paco-Paco' Blanton", N_("developer"), NULL}, @@ -94,7 +94,7 @@ }; /* Order: Alphabetical by Last Name */ -static struct developer patch_writers[] = { +static const struct developer patch_writers[] = { {"John 'rekkanoryo' Bailey", NULL, NULL}, {"Dennis 'EvilDennisR' Ristuccia", N_("Senior Contributor/QA"), NULL}, {"Peter 'Fmoo' Ruibal", NULL, NULL}, @@ -104,7 +104,7 @@ }; /* Order: Alphabetical by Last Name */ -static struct developer retired_developers[] = { +static const struct developer retired_developers[] = { {"Herman Bloggs", N_("win32 port"), "herman@bluedigits.com"}, {"Jim Duchek", N_("maintainer"), "jim@linuxpimps.com"}, {"Rob Flynn", N_("maintainer"), NULL}, @@ -119,7 +119,7 @@ }; /* Order: Alphabetical by Last Name */ -static struct developer retired_patch_writers[] = { +static const struct developer retired_patch_writers[] = { {"Felipe 'shx' Contreras", NULL, NULL}, {"Decklin Foster", NULL, NULL}, {"Peter 'Bleeter' Lawler", NULL, NULL}, @@ -129,7 +129,7 @@ }; /* Order: Code, then Alphabetical by Last Name */ -static struct translator current_translators[] = { +static const struct translator current_translators[] = { {N_("Afrikaans"), "af", "Friedel Wolff", "friedel@translate.org.za"}, {N_("Arabic"), "ar", "Khaled Hosny", "khaledhosny@eglug.org"}, {N_("Belarusian Latin"), "be@latin", "Ihar Hrachyshka", "ihar.hrachyshka@gmail.com"}, @@ -221,7 +221,7 @@ }; -static struct translator past_translators[] = { +static const struct translator past_translators[] = { {N_("Amharic"), "am", "Daniel Yacob", NULL}, {N_("Arabic"), "ar", "Mohamed Magdy", "alnokta@yahoo.com"}, {N_("Bulgarian"), "bg", "Hristo Todorov", NULL}, @@ -271,7 +271,7 @@ {NULL, NULL, NULL, NULL} }; -static struct artist artists[] = { +static const struct artist artists[] = { {"Hylke Bons", "h.bons@student.rug.nl"}, {NULL, NULL} };
--- a/pidgin/gtkimhtml.c Fri Oct 26 00:13:18 2007 +0000 +++ b/pidgin/gtkimhtml.c Fri Oct 26 04:59:23 2007 +0000 @@ -113,7 +113,7 @@ /* POINT_SIZE converts from AIM font sizes to a point size scale factor. */ #define MAX_FONT_SIZE 7 #define POINT_SIZE(x) (_point_sizes [MIN ((x > 0 ? x : 1), MAX_FONT_SIZE) - 1]) -static gdouble _point_sizes [] = { .85, .95, 1, 1.2, 1.44, 1.728, 2.0736}; +static const gdouble _point_sizes [] = { .85, .95, 1, 1.2, 1.44, 1.728, 2.0736}; enum { TARGET_HTML, @@ -140,7 +140,7 @@ static char *text_clipboard = NULL; static GtkClipboard *clipboard_selection = NULL; -static GtkTargetEntry selection_targets[] = { +static const GtkTargetEntry selection_targets[] = { #ifndef _WIN32 { "text/html", 0, TARGET_HTML }, #else @@ -151,7 +151,7 @@ { "STRING", 0, TARGET_STRING }, { "TEXT", 0, TARGET_TEXT}}; -static GtkTargetEntry link_drag_drop_targets[] = { +static const GtkTargetEntry link_drag_drop_targets[] = { GTK_IMHTML_DND_TARGETS };
--- a/pidgin/gtkmain.c Fri Oct 26 00:13:18 2007 +0000 +++ b/pidgin/gtkmain.c Fri Oct 26 04:59:23 2007 +0000 @@ -92,7 +92,7 @@ * Lists of signals we wish to catch and those we wish to ignore. * Each list terminated with -1 */ -static int catch_sig_list[] = { +static const int catch_sig_list[] = { SIGSEGV, SIGHUP, SIGINT, @@ -103,7 +103,7 @@ -1 }; -static int ignore_sig_list[] = { +static const int ignore_sig_list[] = { SIGPIPE, -1 };
--- a/pidgin/gtknickcolors.h Fri Oct 26 00:13:18 2007 +0000 +++ b/pidgin/gtknickcolors.h Fri Oct 26 04:59:23 2007 +0000 @@ -25,7 +25,7 @@ #ifndef _PIDGINNICKCOLORS_H_ #define _PIDGINNICKCOLORS_H_ -static GdkColor nick_seed_colors[] = { +static const GdkColor nick_seed_colors[] = { {0, 64764, 59881, 20303}, /* Butter #1 */ {0, 60909, 54484, 0}, /* Butter #2 */ {0, 50372, 41120, 0}, /* Butter #3 */
--- a/pidgin/gtkprefs.c Fri Oct 26 00:13:18 2007 +0000 +++ b/pidgin/gtkprefs.c Fri Oct 26 04:59:23 2007 +0000 @@ -1326,7 +1326,7 @@ }; /* Sorted reverse alphabetically */ - static struct browser possible_browsers[] = { + static const struct browser possible_browsers[] = { {N_("Seamonkey"), "seamonkey"}, {N_("Opera"), "opera"}, {N_("Netscape"), "netscape"},
--- a/pidgin/gtkprivacy.c Fri Oct 26 00:13:18 2007 +0000 +++ b/pidgin/gtkprivacy.c Fri Oct 26 04:59:23 2007 +0000 @@ -75,7 +75,7 @@ const char *text; int num; -} menu_entries[] = +} const menu_entries[] = { { N_("Allow all users to contact me"), PURPLE_PRIVACY_ALLOW_ALL }, { N_("Allow only the users on my buddy list"), PURPLE_PRIVACY_ALLOW_BUDDYLIST }, @@ -84,7 +84,7 @@ { N_("Block only the users below"), PURPLE_PRIVACY_DENY_USERS } }; -static size_t menu_entry_count = sizeof(menu_entries) / sizeof(*menu_entries); +static const size_t menu_entry_count = sizeof(menu_entries) / sizeof(*menu_entries); static PidginPrivacyDialog *privacy_dialog = NULL;
--- a/pidgin/gtksound.c Fri Oct 26 00:13:18 2007 +0000 +++ b/pidgin/gtksound.c Fri Oct 26 04:59:23 2007 +0000 @@ -60,7 +60,7 @@ static gboolean gst_init_failed; #endif /* USE_GSTREAMER */ -static struct pidgin_sound_event sounds[PURPLE_NUM_SOUNDS] = { +static const struct pidgin_sound_event sounds[PURPLE_NUM_SOUNDS] = { {N_("Buddy logs in"), "login", "login.wav"}, {N_("Buddy logs out"), "logout", "logout.wav"}, {N_("Message received"), "im_recv", "receive.wav"},