acl: split initialization of the access_list out into a function

This commit is contained in:
Michael Adam 2009-11-16 01:13:34 +01:00
parent ec4b4d979f
commit 607e8ec0e7

View File

@ -106,6 +106,23 @@ fill_netmask_array (char *bitmask_string, unsigned char array[],
return 0; return 0;
} }
/**
* If the access list has not been set up, create it.
*/
static int init_access_list(void)
{
if (!access_list) {
access_list = vector_create ();
if (!access_list) {
log_message (LOG_ERR,
"Unable to allocate memory for access list");
return -1;
}
}
return 0;
}
/* /*
* Inserts a new access control into the list. The function will figure out * Inserts a new access control into the list. The function will figure out
* whether the location is an IP address (with optional netmask) or a * whether the location is an IP address (with optional netmask) or a
@ -123,17 +140,10 @@ int insert_acl (char *location, acl_access_t access_type)
assert (location != NULL); assert (location != NULL);
/* ret = init_access_list();
* If the access list has not been set up, create it. if (ret != 0) {
*/
if (!access_list) {
access_list = vector_create ();
if (!access_list) {
log_message (LOG_ERR,
"Unable to allocate memory for access list");
return -1; return -1;
} }
}
/* /*
* Start populating the access control structure. * Start populating the access control structure.