summaryrefslogtreecommitdiff
path: root/usr.sbin/ntpd/parse.y
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-08-10 12:41:16 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-08-10 12:41:16 +0000
commit59a04d58f048fb9192fb0bad8a959bb1d6498d04 (patch)
treea3dc4c0cc8f4044c7513396ab7cf720ad4e9016d /usr.sbin/ntpd/parse.y
parentd1d4402f447e6d89ce22c1fa98941cdfe86b6dde (diff)
move memory allocation for new peers into a new function, makes ID allocation
easier
Diffstat (limited to 'usr.sbin/ntpd/parse.y')
-rw-r--r--usr.sbin/ntpd/parse.y13
1 files changed, 3 insertions, 10 deletions
diff --git a/usr.sbin/ntpd/parse.y b/usr.sbin/ntpd/parse.y
index 508df8d0fe6..00a51546f65 100644
--- a/usr.sbin/ntpd/parse.y
+++ b/usr.sbin/ntpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.17 2004/07/29 11:01:48 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.18 2004/08/10 12:41:15 henning Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -41,7 +41,6 @@ static int lineno = 1;
static int errors = 0;
static int pdebug = 1;
char *infile;
-static u_int32_t maxid;
int yyerror(const char *, ...);
int yyparse(void);
@@ -169,10 +168,7 @@ conf_main : LISTEN ON address {
free($2);
YYERROR;
}
- p = calloc(1, sizeof(struct ntp_peer));
- if (p == NULL)
- fatal("conf_main server calloc");
- p->id = ++maxid;
+ p = new_peer();
h->next = NULL;
p->addr = h;
p->addr_head.a = h;
@@ -189,9 +185,7 @@ conf_main : LISTEN ON address {
struct ntp_peer *p;
struct ntp_addr *h, *next;
- if ((p = calloc(1, sizeof(struct ntp_peer))) == NULL)
- fatal("conf_main server calloc");
- p->id = ++maxid;
+ p = new_peer();
for (h = $2->a; h != NULL; h = next) {
next = h->next;
if (h->ss.ss_family != AF_INET &&
@@ -481,7 +475,6 @@ parse_config(char *filename, struct ntpd_conf *xconf)
conf = xconf;
lineno = 1;
errors = 0;
- maxid = 0;
TAILQ_INIT(&conf->listen_addrs);
TAILQ_INIT(&conf->ntp_peers);