constify winecfg
Andreas Mohr
andi at rhlx01.fht-esslingen.de
Sun Jun 26 12:01:24 CDT 2005
Hi all,
constify all needlessly non-const winecfg structs.
Now
andi 21168 7.7 1.7 1590128 9096 pts/3 S 18:34 0:02 /usr/local/src/
-rwxr-xr-x 1 andi adm 2622743 Jun 26 18:23 winecfg.exe.so
versus
andi 21544 13.8 1.7 1590128 9088 pts/3 S 18:45 0:01 /usr/local/src/
-rwxr-xr-x 1 andi adm 2622831 Jun 26 18:43 winecfg.exe.so
So we save 8kB memory (slightly bigger non-stripped executable, though).
Also make sure to not abuse those poor acronyms ("ALSA" etc.).
Andreas Mohr
-------------- next part --------------
Determining best CVS host...
Using CVSROOT :pserver:cvs at rhlx01.fht-esslingen.de:/home/wine
cvs diff: Diffing programs/winecfg
Index: programs/winecfg/appdefaults.c
===================================================================
RCS file: /home/wine/wine/programs/winecfg/appdefaults.c,v
retrieving revision 1.17
diff -u -r1.17 appdefaults.c
--- programs/winecfg/appdefaults.c 23 Jun 2005 11:42:54 -0000 1.17
+++ programs/winecfg/appdefaults.c 26 Jun 2005 16:45:13 -0000
@@ -291,7 +291,7 @@
static void on_winver_change(HWND dialog)
{
int selection = SendDlgItemMessage(dialog, IDC_WINVER, CB_GETCURSEL, 0, 0);
- VERSION_DESC *ver = getWinVersions();
+ const VERSION_DESC *ver = getWinVersions();
if (selection == 0)
{
Index: programs/winecfg/audio.c
===================================================================
RCS file: /home/wine/wine/programs/winecfg/audio.c,v
retrieving revision 1.9
diff -u -r1.9 audio.c
--- programs/winecfg/audio.c 23 Jun 2005 11:42:54 -0000 1.9
+++ programs/winecfg/audio.c 26 Jun 2005 16:45:13 -0000
@@ -110,7 +110,7 @@
if(!stat("/proc/asound", &buf))
{
driversFound[numFound] = "alsa";
- name[numFound] = "Alsa";
+ name[numFound] = "ALSA";
numFound++;
}
@@ -128,7 +128,7 @@
if(!spawnvp(_P_WAIT, "/bin/sh", argv_new))
{
driversFound[numFound] = "jack";
- name[numFound] = "jack";
+ name[numFound] = "JACK";
numFound++;
}
Index: programs/winecfg/drivedetect.c
===================================================================
RCS file: /home/wine/wine/programs/winecfg/drivedetect.c,v
retrieving revision 1.8
diff -u -r1.8 drivedetect.c
--- programs/winecfg/drivedetect.c 16 Jun 2005 15:59:36 -0000 1.8
+++ programs/winecfg/drivedetect.c 26 Jun 2005 16:45:13 -0000
@@ -44,13 +44,13 @@
#ifdef HAVE_MNTENT_H
-static DEV_NODES sDeviceNodes[] = {
+static const DEV_NODES sDeviceNodes[] = {
{"/dev/fd", DRIVE_REMOVABLE},
{"/dev/cdrom", DRIVE_CDROM},
{"",0}
};
-static const char *ignored_fstypes[] = {
+static const char * const ignored_fstypes[] = {
"devpts",
"tmpfs",
"proc",
@@ -61,7 +61,7 @@
NULL
};
-static const char *ignored_mnt_dirs[] = {
+static const char * const ignored_mnt_dirs[] = {
"/boot",
NULL
};
@@ -82,7 +82,7 @@
static BOOL should_ignore_fstype(char *type)
{
- const char **s;
+ const char * const *s;
for (s = ignored_fstypes; *s; s++)
if (!strcmp(*s, type)) return TRUE;
@@ -92,7 +92,7 @@
static BOOL should_ignore_mnt_dir(char *dir)
{
- const char **s;
+ const char * const *s;
for (s = ignored_mnt_dirs; *s; s++)
if (!strcmp(*s, dir)) return TRUE;
@@ -138,7 +138,7 @@
case FSTAB_OPEN:
if (gui_mode)
{
- static const char *s = "Could not open your mountpoint description table.\n\nOpening of /etc/fstab failed: %s";
+ static const char * const s = "Could not open your mountpoint description table.\n\nOpening of /etc/fstab failed: %s";
len = snprintf(NULL, 0, s, strerror(errno));
buffer = HeapAlloc(GetProcessHeap(), 0, len + 1);
snprintf(buffer, len, s, strerror(errno));
Index: programs/winecfg/properties.c
===================================================================
RCS file: /home/wine/wine/programs/winecfg/properties.c,v
retrieving revision 1.11
diff -u -r1.11 properties.c
--- programs/winecfg/properties.c 20 Jun 2005 18:35:57 -0000 1.11
+++ programs/winecfg/properties.c 26 Jun 2005 16:45:13 -0000
@@ -24,7 +24,7 @@
#include "properties.h"
-static VERSION_DESC sWinVersions[] = {
+static const VERSION_DESC sWinVersions[] = {
{"win2003", "Windows 2003"},
{"winxp", "Windows XP"},
{"win2k", "Windows 2000"},
@@ -39,7 +39,7 @@
{"", ""}
};
-static DLL_DESC sDLLType[] = {
+static const DLL_DESC sDLLType[] = {
{"oleaut32", DLL_BUILTIN},
{"ole32", DLL_BUILTIN},
{"commdlg", DLL_BUILTIN},
@@ -57,12 +57,12 @@
{"", -1}
};
-static AUDIO_DRIVER sAudioDrivers[] = {
- {"Alsa", "alsa"},
+static const AUDIO_DRIVER sAudioDrivers[] = {
+ {"ALSA", "alsa"},
{"aRts", "arts"},
{"OSS", "oss"},
- {"Jack", "jack"},
- {"Nas", "nas"},
+ {"JACK", "jack"},
+ {"NAS", "nas"},
{"Audio IO(Solaris)", "audioio"},
{"Disable sound", ""},
{"", ""}
@@ -72,7 +72,7 @@
/*****************************************************************************
*/
-VERSION_DESC* getWinVersions(void)
+const VERSION_DESC* getWinVersions(void)
{
return sWinVersions;
}
@@ -80,14 +80,14 @@
/*****************************************************************************
*/
-DLL_DESC* getDLLDefaults(void)
+const DLL_DESC* getDLLDefaults(void)
{
return sDLLType;
}
/*****************************************************************************
*/
-AUDIO_DRIVER* getAudioDrivers(void)
+const AUDIO_DRIVER* getAudioDrivers(void)
{
return sAudioDrivers;
}
Index: programs/winecfg/properties.h
===================================================================
RCS file: /home/wine/wine/programs/winecfg/properties.h,v
retrieving revision 1.12
diff -u -r1.12 properties.h
--- programs/winecfg/properties.h 25 Feb 2005 13:58:45 -0000 1.12
+++ programs/winecfg/properties.h 26 Jun 2005 16:45:13 -0000
@@ -93,10 +93,10 @@
int nType;
} DEV_NODES;
-VERSION_DESC *getWinVersions(void);
-VERSION_DESC *getDOSVersions(void);
-DLL_DESC *getDLLDefaults(void);
-AUDIO_DRIVER *getAudioDrivers(void);
+const VERSION_DESC *getWinVersions(void);
+const VERSION_DESC *getDOSVersions(void);
+const DLL_DESC *getDLLDefaults(void);
+const AUDIO_DRIVER *getAudioDrivers(void);
char* getVersionFromDescription(VERSION_DESC *pVer, char *desc);
char* getDescriptionFromVersion(VERSION_DESC *pVer, char *ver);
More information about the wine-patches
mailing list