summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-09-07 17:44:24 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-09-12 05:26:16 +0200
commit6638d1036688f7b0f15a1a18c9a251ab0a7ab626 (patch)
tree31669a1f287161bc78256798602ce9e27b5cb997 /source3/lib
parentac804f0d7f5a93ff2710e213d9213ad9960a15d6 (diff)
downloadsamba-6638d1036688f7b0f15a1a18c9a251ab0a7ab626.tar.gz
samba-6638d1036688f7b0f15a1a18c9a251ab0a7ab626.tar.bz2
samba-6638d1036688f7b0f15a1a18c9a251ab0a7ab626.zip
smbd: Remove pre-allocation of ACL array in sys_acl_init()
Instead, this is just handled with realloc in sys_acl_create_entry() This allows us to remove the size element from the SMB_ACL_T. Andrew Bartlett
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/sysacls.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/source3/lib/sysacls.c b/source3/lib/sysacls.c
index 1b6eb9a35c..a5430d6a0d 100644
--- a/source3/lib/sysacls.c
+++ b/source3/lib/sysacls.c
@@ -249,25 +249,19 @@ char *sys_acl_to_text(const struct smb_acl_t *acl_d, ssize_t *len_p)
return text;
}
-SMB_ACL_T sys_acl_init(int count)
+SMB_ACL_T sys_acl_init(void)
{
SMB_ACL_T a;
- if (count < 0) {
- errno = EINVAL;
- return NULL;
- }
-
if ((a = talloc(NULL, struct smb_acl_t)) == NULL) {
errno = ENOMEM;
return NULL;
}
- a->size = count + 1;
a->count = 0;
a->next = -1;
- a->acl = talloc_array(a, struct smb_acl_entry, count+1);
+ a->acl = talloc_array(a, struct smb_acl_entry, 0);
if (!a->acl) {
TALLOC_FREE(a);
errno = ENOMEM;
@@ -281,22 +275,25 @@ int sys_acl_create_entry(SMB_ACL_T *acl_p, SMB_ACL_ENTRY_T *entry_p)
{
SMB_ACL_T acl_d;
SMB_ACL_ENTRY_T entry_d;
+ struct smb_acl_entry *acl;
if (acl_p == NULL || entry_p == NULL || (acl_d = *acl_p) == NULL) {
errno = EINVAL;
return -1;
}
- if (acl_d->count >= acl_d->size) {
- errno = ENOSPC;
+ acl = talloc_realloc(acl_d, acl_d->acl, struct smb_acl_entry, acl_d->count+1);
+ if (!acl) {
+ errno = ENOMEM;
return -1;
}
-
- entry_d = &acl_d->acl[acl_d->count++];
+ acl_d->acl = acl;
+ entry_d = &acl_d->acl[acl_d->count];
entry_d->a_type = SMB_ACL_TAG_INVALID;
entry_d->a_perm = 0;
*entry_p = entry_d;
+ acl_d->count++;
return 0;
}