Finesse allocation of memory for "struct crec" cache entries.

These normally have enough space for a name of up to SMALLDNAME characters.
When used to hold /etc/hosts entries, they are allocated with just enough
bytes for the name held. When used to hold other configured stuff, (CNAMES
DS records. DHCP names etc), the name is replaced by a pointer to a string
held elsewhere, and F_NAMEP set. Hence only enough space to hold a char *
is needed, rather than SMALLDNAME bytes.
This commit is contained in:
Simon Kelley
2018-09-26 16:50:35 +01:00
parent 48b090cb5c
commit 3a610a007f
2 changed files with 13 additions and 11 deletions

View File

@@ -442,6 +442,9 @@ struct crec {
} name;
};
#define SIZEOF_BARE_CREC (sizeof(struct crec) - SMALLDNAME)
#define SIZEOF_POINTER_CREC (sizeof(struct crec) + sizeof(char *) - SMALLDNAME)
#define F_IMMORTAL (1u<<0)
#define F_NAMEP (1u<<1)
#define F_REVERSE (1u<<2)