diff options
| author | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2009-06-25 12:46:59 +0000 |
|---|---|---|
| committer | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2009-06-25 12:46:59 +0000 |
| commit | aa015c8e4ad07fbe76ec137fa491c89856b871e0 (patch) | |
| tree | 2ef84b1a3d387c8edf2b81194552ad8337bd003b /lib/libc/posix1e/acl_init.c | |
| parent | e68920db5fd8618cacc12bd225f98e1819c2617d (diff) | |
Notes
Diffstat (limited to 'lib/libc/posix1e/acl_init.c')
| -rw-r--r-- | lib/libc/posix1e/acl_init.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/libc/posix1e/acl_init.c b/lib/libc/posix1e/acl_init.c index 905df60bce0f..4fe403777ddb 100644 --- a/lib/libc/posix1e/acl_init.c +++ b/lib/libc/posix1e/acl_init.c @@ -38,10 +38,22 @@ __FBSDID("$FreeBSD$"); #include <errno.h> #include <stdlib.h> #include <string.h> +#include <assert.h> + +#include "acl_support.h" + +#ifndef CTASSERT +#define CTASSERT(x) _CTASSERT(x, __LINE__) +#define _CTASSERT(x, y) __CTASSERT(x, y) +#define __CTASSERT(x, y) typedef char __assert_ ## y [(x) ? 1 : -1] +#endif + +CTASSERT(1 << _ACL_T_ALIGNMENT_BITS > sizeof(struct acl_t_struct)); acl_t acl_init(int count) { + int error; acl_t acl; if (count > ACL_MAX_ENTRIES) { @@ -53,11 +65,14 @@ acl_init(int count) return (NULL); } - acl = malloc(sizeof(struct acl_t_struct)); - if (acl != NULL) { - bzero(acl, sizeof(struct acl_t_struct)); - acl->ats_acl.acl_maxcnt = ACL_MAX_ENTRIES; - } + error = posix_memalign((void *)&acl, 1 << _ACL_T_ALIGNMENT_BITS, + sizeof(struct acl_t_struct)); + if (error) + return (NULL); + + bzero(acl, sizeof(struct acl_t_struct)); + acl->ats_brand = ACL_BRAND_UNKNOWN; + acl->ats_acl.acl_maxcnt = ACL_MAX_ENTRIES; return (acl); } |
