mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-16 23:50:32 +00:00
Simplify getnameinfo (#196)
The getnameinfo implementation requires an address -> name lookup on the hosts file (ie struct HostsTxt) and the previous implementation used flags to check whether HostsTxt was sorted according to address or name, and then re-sorted it if necessary. Now getnameinfo lookup does not require sorting, it does a simple linear lookup, and so the related code was simplified See #172 for discussion.
This commit is contained in:
parent
1f87640d17
commit
98c53ae526
7 changed files with 21 additions and 46 deletions
|
@ -61,7 +61,6 @@ const struct HostsTxt *GetHostsTxt(void) {
|
|||
init = &g_hoststxt_init;
|
||||
if (!g_hoststxt) {
|
||||
g_hoststxt = &init->ht;
|
||||
init->ht.sorted_by = HOSTSTXT_NOT_SORTED;
|
||||
init->ht.entries.n = pushpop(ARRAYLEN(init->entries));
|
||||
init->ht.entries.p = init->entries;
|
||||
init->ht.strings.n = pushpop(ARRAYLEN(init->strings));
|
||||
|
@ -75,7 +74,7 @@ const struct HostsTxt *GetHostsTxt(void) {
|
|||
/* TODO(jart): Elevate robustness. */
|
||||
}
|
||||
fclose(f);
|
||||
SortHostsTxt(g_hoststxt, HOSTSTXT_SORTEDBYNAME);
|
||||
SortHostsTxt(g_hoststxt);
|
||||
}
|
||||
return g_hoststxt;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue