diff options
author | Ron Yorston <rmy@pobox.com> | 2018-03-04 08:56:04 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-03-04 08:56:04 +0000 |
commit | 31997b1796bdaf5734f5fff1a20a637d8872419d (patch) | |
tree | 9c27f6741a1149059cb4f2cb324f6b2ee913e428 /win32/mntent.c | |
parent | 13cb88b0f6f2a69076e91858fbbdd0c65697e621 (diff) | |
download | busybox-w32-31997b1796bdaf5734f5fff1a20a637d8872419d.tar.gz busybox-w32-31997b1796bdaf5734f5fff1a20a637d8872419d.tar.bz2 busybox-w32-31997b1796bdaf5734f5fff1a20a637d8872419d.zip |
win32: reduce amount of static data
It appears that uninitialised static variables are placed in the
data section rather than bss, increasing the size of the binary.
Rewrite some code to reduce the amount of static data.
Diffstat (limited to 'win32/mntent.c')
-rw-r--r-- | win32/mntent.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/win32/mntent.c b/win32/mntent.c index 9b04a9c5e..f9a2d26d4 100644 --- a/win32/mntent.c +++ b/win32/mntent.c | |||
@@ -7,6 +7,11 @@ | |||
7 | struct mntdata { | 7 | struct mntdata { |
8 | DWORD flags; | 8 | DWORD flags; |
9 | int index; | 9 | int index; |
10 | struct mntent me; | ||
11 | char mnt_fsname[4]; | ||
12 | char mnt_dir[4]; | ||
13 | char mnt_type[100]; | ||
14 | char mnt_opts[4]; | ||
10 | }; | 15 | }; |
11 | 16 | ||
12 | FILE *setmntent(const char *file UNUSED_PARAM, const char *mode UNUSED_PARAM) | 17 | FILE *setmntent(const char *file UNUSED_PARAM, const char *mode UNUSED_PARAM) |
@@ -26,34 +31,35 @@ FILE *setmntent(const char *file UNUSED_PARAM, const char *mode UNUSED_PARAM) | |||
26 | struct mntent *getmntent(FILE *stream) | 31 | struct mntent *getmntent(FILE *stream) |
27 | { | 32 | { |
28 | struct mntdata *data = (struct mntdata *)stream; | 33 | struct mntdata *data = (struct mntdata *)stream; |
29 | static char mnt_fsname[4]; | ||
30 | static char mnt_dir[4]; | ||
31 | static char mnt_type[100]; | ||
32 | static char mnt_opts[4]; | ||
33 | static struct mntent my_mount_entry = | ||
34 | { mnt_fsname, mnt_dir, mnt_type, mnt_opts, 0, 0 }; | ||
35 | struct mntent *entry; | 34 | struct mntent *entry; |
36 | 35 | ||
36 | data->me.mnt_fsname = data->mnt_fsname; | ||
37 | data->me.mnt_dir = data->mnt_dir; | ||
38 | data->me.mnt_type = data->mnt_type; | ||
39 | data->me.mnt_opts = data->mnt_opts; | ||
40 | data->me.mnt_freq = 0; | ||
41 | data->me.mnt_passno = 0; | ||
42 | |||
37 | entry = NULL; | 43 | entry = NULL; |
38 | while ( ++data->index < 26 ) { | 44 | while ( ++data->index < 26 ) { |
39 | if ( (data->flags & 1<<data->index) != 0 ) { | 45 | if ( (data->flags & 1<<data->index) != 0 ) { |
40 | mnt_fsname[0] = 'A' + data->index; | 46 | data->mnt_fsname[0] = 'A' + data->index; |
41 | mnt_fsname[1] = ':'; | 47 | data->mnt_fsname[1] = ':'; |
42 | mnt_fsname[2] = '\0'; | 48 | data->mnt_fsname[2] = '\0'; |
43 | mnt_dir[0] = 'A' + data->index; | 49 | data->mnt_dir[0] = 'A' + data->index; |
44 | mnt_dir[1] = ':'; | 50 | data->mnt_dir[1] = ':'; |
45 | mnt_dir[2] = '\\'; | 51 | data->mnt_dir[2] = '\\'; |
46 | mnt_dir[3] = '\0'; | 52 | data->mnt_dir[3] = '\0'; |
47 | mnt_type[0] = '\0'; | 53 | data->mnt_type[0] = '\0'; |
48 | mnt_opts[0] = '\0'; | 54 | data->mnt_opts[0] = '\0'; |
49 | 55 | ||
50 | if ( GetDriveType(mnt_dir) == DRIVE_FIXED ) { | 56 | if ( GetDriveType(data->mnt_dir) == DRIVE_FIXED ) { |
51 | if ( !GetVolumeInformation(mnt_dir, NULL, 0, NULL, NULL, | 57 | if ( !GetVolumeInformation(data->mnt_dir, NULL, 0, NULL, NULL, |
52 | NULL, mnt_type, 100) ) { | 58 | NULL, data->mnt_type, 100) ) { |
53 | mnt_type[0] = '\0'; | 59 | data->mnt_type[0] = '\0'; |
54 | } | 60 | } |
55 | 61 | ||
56 | entry = &my_mount_entry; | 62 | entry = &data->me; |
57 | break; | 63 | break; |
58 | } | 64 | } |
59 | } | 65 | } |