summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2009-11-16 01:13:34 +0100
committerMichael Adam <obnox@samba.org>2009-11-17 17:30:19 +0100
commit607e8ec0e74de155b5a736f29b74f9b32f734a41 (patch)
tree447d5e3f33936c25ef2b172bd7979ca58dbc6742
parentec4b4d979f90405ea455f7403860931511075751 (diff)
downloadtinyproxy-607e8ec0e74de155b5a736f29b74f9b32f734a41.tar.gz
tinyproxy-607e8ec0e74de155b5a736f29b74f9b32f734a41.zip
acl: split initialization of the access_list out into a function
Diffstat (limited to '')
-rw-r--r--src/acl.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/acl.c b/src/acl.c
index 5802769..612d44e 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -106,6 +106,23 @@ fill_netmask_array (char *bitmask_string, unsigned char array[],
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
* whether the location is an IP address (with optional netmask) or a
@@ -123,16 +140,9 @@ int insert_acl (char *location, acl_access_t access_type)
assert (location != NULL);
- /*
- * If the access list has not been set up, create it.
- */
- if (!access_list) {
- access_list = vector_create ();
- if (!access_list) {
- log_message (LOG_ERR,
- "Unable to allocate memory for access list");
- return -1;
- }
+ ret = init_access_list();
+ if (ret != 0) {
+ return -1;
}
/*