diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-02-18 18:40:46 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-02-18 18:40:46 +0300 |
commit | c22c8be47f7ef8e3018dbb301f65f512b4e83535 (patch) | |
tree | 95af66fd03b9542e58e586c316d900fc426ec2ab /src/dns.c | |
parent | 474b4f809c7321c47c0ddc68b563dd69cbf2cef9 (diff) | |
download | rspamd-c22c8be47f7ef8e3018dbb301f65f512b4e83535.tar.gz rspamd-c22c8be47f7ef8e3018dbb301f65f512b4e83535.zip |
Optimize DNS parsing.
Suggested by: Igor Sysoev
Diffstat (limited to 'src/dns.c')
-rw-r--r-- | src/dns.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -755,8 +755,8 @@ end: return TRUE; } -#define GET16(x) do {if (*remain < sizeof (guint16)) {goto err;} memcpy (&(x), p, sizeof (guint16)); (x) = ntohs ((x)); p += sizeof (guint16); *remain -= sizeof (guint16); } while(0) -#define GET32(x) do {if (*remain < sizeof (guint32)) {goto err;} memcpy (&(x), p, sizeof (guint32)); (x) = ntohl ((x)); p += sizeof (guint32); *remain -= sizeof (guint32); } while(0) +#define GET16(x) do {(x) = ((*p) << 8) + *(p + 1); p += sizeof (guint16); *remain -= sizeof (guint16); } while(0) +#define GET32(x) do {(x) = ((*p) << 24) + ((*(p + 1)) << 16) + ((*(p + 2)) << 8) + *(p + 3); p += sizeof (guint32); *remain -= sizeof (guint32); } while(0) static gint dns_parse_rr (guint8 *in, union rspamd_reply_element *elt, guint8 **pos, struct rspamd_dns_reply *rep, gint *remain) |