diff options
author | Denys Vlasenko | 2009-10-13 16:27:11 +0200 |
---|---|---|
committer | Denys Vlasenko | 2009-10-13 16:27:11 +0200 |
commit | 94466b8b8c8b8dbdc496eefe947ee364fa85fdfb (patch) | |
tree | 82df0787bc9b2e7f10ba1b370b029ac6bb22fe97 /networking/libiproute/ll_map.c | |
parent | 0bf44d00a42dec70514c2e51926f4ca37b4b2367 (diff) | |
download | busybox-94466b8b8c8b8dbdc496eefe947ee364fa85fdfb.zip busybox-94466b8b8c8b8dbdc496eefe947ee364fa85fdfb.tar.gz |
libiproute: code and data shrink
function old new delta
rtnl_a2n - 126 +126
ll_remember_index 233 263 +30
find_by_index 26 36 +10
rtnl_rtprot_initialize 66 70 +4
static.unit_chars 7 9 +2
rtnl_rttable_initialize 73 75 +2
rtnl_rtscope_initialize 83 85 +2
rtnl_rtrealm_initialize 43 45 +2
rtnl_rtdsfield_initialize 43 45 +2
rtnl_rttable_n2a 62 63 +1
rtnl_rtscope_n2a 62 63 +1
rtnl_rtrealm_n2a 62 63 +1
rtnl_dsfield_n2a 70 71 +1
ll_init_map 36 33 -3
make_human_readable_str 262 258 -4
static.fmt 97 92 -5
static.fmt_tenths 10 - -10
static.str 21 4 -17
static.res 20 - -20
static.cache 24 4 -20
idxmap 64 4 -60
rtnl_rttable_a2n 154 39 -115
rtnl_rtscope_a2n 159 39 -120
rtnl_rtrealm_a2n 159 39 -120
rtnl_rtprot_a2n 159 39 -120
rtnl_dsfield_a2n 162 39 -123
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 12/11 up/down: 184/-737) Total: -553 bytes
text data bss dec hex filename
820376 445 7668 828489 ca449 busybox_old
819950 445 7548 827943 ca227 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/libiproute/ll_map.c')
-rw-r--r-- | networking/libiproute/ll_map.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/networking/libiproute/ll_map.c b/networking/libiproute/ll_map.c index 62528cc..3c4ef2c 100644 --- a/networking/libiproute/ll_map.c +++ b/networking/libiproute/ll_map.c @@ -27,15 +27,16 @@ struct idxmap { char name[16]; }; -static struct idxmap *idxmap[16]; +static struct idxmap **idxmap; /* treat as *idxmap[16] */ static struct idxmap *find_by_index(int idx) { struct idxmap *im; - for (im = idxmap[idx & 0xF]; im; im = im->next) - if (im->index == idx) - return im; + if (idxmap) + for (im = idxmap[idx & 0xF]; im; im = im->next) + if (im->index == idx) + return im; return NULL; } @@ -59,8 +60,10 @@ int FAST_FUNC ll_remember_index(const struct sockaddr_nl *who UNUSED_PARAM, if (tb[IFLA_IFNAME] == NULL) return 0; - h = ifi->ifi_index & 0xF; + if (!idxmap) + idxmap = xzalloc(sizeof(idxmap[0]) * 16); + h = ifi->ifi_index & 0xF; for (imp = &idxmap[h]; (im = *imp) != NULL; imp = &im->next) if (im->index == ifi->ifi_index) goto found; @@ -152,13 +155,15 @@ int FAST_FUNC xll_name_to_index(const char *name) ret = icache; goto out; } - for (i = 0; i < 16; i++) { - for (im = idxmap[i]; im; im = im->next) { - if (strcmp(im->name, name) == 0) { - icache = im->index; - strcpy(ncache, name); - ret = im->index; - goto out; + if (idxmap) { + for (i = 0; i < 16; i++) { + for (im = idxmap[i]; im; im = im->next) { + if (strcmp(im->name, name) == 0) { + icache = im->index; + strcpy(ncache, name); + ret = im->index; + goto out; + } } } } @@ -195,6 +200,6 @@ int FAST_FUNC xll_name_to_index(const char *name) int FAST_FUNC ll_init_map(struct rtnl_handle *rth) { xrtnl_wilddump_request(rth, AF_UNSPEC, RTM_GETLINK); - xrtnl_dump_filter(rth, ll_remember_index, &idxmap); + xrtnl_dump_filter(rth, ll_remember_index, NULL); return 0; } |