resetting manifest requested domain to floor
[platform/upstream/acl.git] / libacl / acl_init.c
1 /*
2   File: acl_init.c
3
4   Copyright (C) 1999, 2000
5   Andreas Gruenbacher, <a.gruenbacher@bestbits.at>
6
7   This program is free software; you can redistribute it and/or
8   modify it under the terms of the GNU Lesser General Public
9   License as published by the Free Software Foundation; either
10   version 2.1 of the License, or (at your option) any later version.
11
12   This program is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15   Lesser General Public License for more details.
16
17   You should have received a copy of the GNU Lesser General Public
18   License along with this library; if not, write to the Free Software
19   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22 #include "libacl.h"
23
24
25 acl_obj *
26 __acl_init_obj(int count)
27 {
28         acl_obj *acl_obj_p = new_obj_p(acl);
29         if (!acl_obj_p)
30                 return NULL;
31         acl_obj_p->aused = 0;
32         acl_obj_p->aprev = acl_obj_p->anext = (acl_entry_obj *)acl_obj_p;
33         acl_obj_p->acurr = (acl_entry_obj *)acl_obj_p;
34
35         /* aprealloc points to an array of pre-allocated ACL entries.
36            Entries between [aprealloc, aprealloc_end) are still available.
37            Pre-allocated entries are consumed from the last entry to the
38            first and aprealloc_end decremented. After all pre-allocated
39            entries are consumed, further entries are malloc'ed.
40            aprealloc == aprealloc_end is true when no more pre-allocated        
41            entries are available. */
42
43         if (count > 0)
44                 acl_obj_p->aprealloc = (acl_entry_obj *)
45                         malloc(count * sizeof(acl_entry_obj));
46         else
47                 acl_obj_p->aprealloc = NULL;
48         if (acl_obj_p->aprealloc != NULL)
49                 acl_obj_p->aprealloc_end = acl_obj_p->aprealloc + count;
50         else
51                 acl_obj_p->aprealloc_end = NULL;
52
53         return acl_obj_p;
54 }
55
56
57 /* 23.4.20 */
58 acl_t
59 acl_init(int count)
60 {
61         acl_obj *obj;
62         if (count < 0) {
63                 errno = EINVAL;
64                 return NULL;
65         }
66         obj = __acl_init_obj(count);
67         return int2ext(obj);
68 }
69