|
|
| version 1.1.4.2, 2012/05/23 10:56:03 | version 1.1.4.3, 2012/05/23 11:49:35 |
|---|---|
| Line 170 mpool_malloc(mpool_t * __restrict mp, u_int size, cons | Line 170 mpool_malloc(mpool_t * __restrict mp, u_int size, cons |
| u_int align; | u_int align; |
| if (!mp) { | if (!mp) { |
| sess_SetErr(EINVAL, "Pool not specified"); | io_SetErr(EINVAL, "Pool not specified"); |
| return NULL; | return NULL; |
| } | } |
| if (size > MEM_ALLOC_MAX) { | if (size > MEM_ALLOC_MAX) { |
| sess_SetErr(ENOMEM, "Memory size is too large"); | io_SetErr(ENOMEM, "Memory size is too large"); |
| return NULL; | return NULL; |
| } else | } else |
| size = (size + 3) & ~3; /* must align to 4 because needed room for sentinels */ | size = (size + 3) & ~3; /* must align to 4 because needed room for sentinels */ |
| Line 188 mpool_malloc(mpool_t * __restrict mp, u_int size, cons | Line 188 mpool_malloc(mpool_t * __restrict mp, u_int size, cons |
| /* quota */ | /* quota */ |
| if (mp->pool_quota.max && | if (mp->pool_quota.max && |
| (mp->pool_quota.curr + size) > mp->pool_quota.max) { | (mp->pool_quota.curr + size) > mp->pool_quota.max) { |
| sess_SetErr(ENOMEM, "Max.allocate memory quota has been reached"); | io_SetErr(ENOMEM, "Max.allocate memory quota has been reached"); |
| mpool_unlock(mp); | mpool_unlock(mp); |
| return NULL; | return NULL; |
| } | } |
| Line 251 mpool_realloc(mpool_t * __restrict mp, void * __restri | Line 251 mpool_realloc(mpool_t * __restrict mp, void * __restri |
| return mpool_malloc(mp, newsize, memname); | return mpool_malloc(mp, newsize, memname); |
| if (!mp) { | if (!mp) { |
| sess_SetErr(EINVAL, "Pool not specified"); | io_SetErr(EINVAL, "Pool not specified"); |
| return NULL; | return NULL; |
| } | } |
| /* check address range & sentinel */ | /* check address range & sentinel */ |
| if (MEM_BADADDR(data) || MEM_CORRUPT(data)) { | if (MEM_BADADDR(data) || MEM_CORRUPT(data)) { |
| sess_SetErr(EFAULT, "Corrupted memory address"); | io_SetErr(EFAULT, "Corrupted memory address"); |
| return NULL; | return NULL; |
| } else { | } else { |
| osize = ((u_int*)data)[-2] * sizeof(u_int); | osize = ((u_int*)data)[-2] * sizeof(u_int); |
| Line 264 mpool_realloc(mpool_t * __restrict mp, void * __restri | Line 264 mpool_realloc(mpool_t * __restrict mp, void * __restri |
| } | } |
| /* prepare new size */ | /* prepare new size */ |
| if (newsize > MEM_ALLOC_MAX) { | if (newsize > MEM_ALLOC_MAX) { |
| sess_SetErr(ENOMEM, "Memory size is too large"); | io_SetErr(ENOMEM, "Memory size is too large"); |
| return NULL; | return NULL; |
| } else { | } else { |
| newsize = (newsize + 3) & ~3; /* must align to 4 because needed room for sentinels */ | newsize = (newsize + 3) & ~3; /* must align to 4 because needed room for sentinels */ |
| Line 276 mpool_realloc(mpool_t * __restrict mp, void * __restri | Line 276 mpool_realloc(mpool_t * __restrict mp, void * __restri |
| /* quota */ | /* quota */ |
| if (mp->pool_quota.max && | if (mp->pool_quota.max && |
| (mp->pool_quota.curr + ((u_long) newsize - osize)) > mp->pool_quota.max) { | (mp->pool_quota.curr + ((u_long) newsize - osize)) > mp->pool_quota.max) { |
| sess_SetErr(ENOMEM, "Max.allocate memory quota has been reached"); | io_SetErr(ENOMEM, "Max.allocate memory quota has been reached"); |
| mpool_unlock(mp); | mpool_unlock(mp); |
| return NULL; | return NULL; |
| } | } |
| Line 297 mpool_realloc(mpool_t * __restrict mp, void * __restri | Line 297 mpool_realloc(mpool_t * __restrict mp, void * __restri |
| /* memory block not found! */ | /* memory block not found! */ |
| if (!m) { | if (!m) { |
| mpool_unlock(mp); | mpool_unlock(mp); |
| sess_SetErr(EFAULT, "Memory block not found"); | io_SetErr(EFAULT, "Memory block not found"); |
| return NULL; | return NULL; |
| } | } |
| Line 354 mpool_purge(mpool_t * __restrict mp, u_int atmost) | Line 354 mpool_purge(mpool_t * __restrict mp, u_int atmost) |
| struct tagAlloc *m, *tmp; | struct tagAlloc *m, *tmp; |
| if (!mp) { | if (!mp) { |
| sess_SetErr(EINVAL, "Pool not specified"); | io_SetErr(EINVAL, "Pool not specified"); |
| return -1; | return -1; |
| } | } |
| Line 403 mpool_free(mpool_t * __restrict mp, void * __restrict | Line 403 mpool_free(mpool_t * __restrict mp, void * __restrict |
| struct tagAlloc *m, *tmp; | struct tagAlloc *m, *tmp; |
| if (!mp) { | if (!mp) { |
| sess_SetErr(EINVAL, "Pool not specified"); | io_SetErr(EINVAL, "Pool not specified"); |
| return -1; | return -1; |
| } | } |
| /* check address range & sentinel */ | /* check address range & sentinel */ |
| if (MEM_BADADDR(data) || MEM_CORRUPT(data)) { | if (MEM_BADADDR(data) || MEM_CORRUPT(data)) { |
| sess_SetErr(EFAULT, "Corrupted memory address"); | io_SetErr(EFAULT, "Corrupted memory address"); |
| return -2; | return -2; |
| } else | } else |
| idx = BucketIndex(((u_int*)data)[-2] * sizeof(u_int)); | idx = BucketIndex(((u_int*)data)[-2] * sizeof(u_int)); |
| Line 460 mpool_free2(mpool_t * __restrict mp, u_int size, const | Line 460 mpool_free2(mpool_t * __restrict mp, u_int size, const |
| struct tagAlloc *m, *tmp; | struct tagAlloc *m, *tmp; |
| if (!mp || !memname) { | if (!mp || !memname) { |
| sess_SetErr(EINVAL, "Pool or memory name is not specified"); | io_SetErr(EINVAL, "Pool or memory name is not specified"); |
| return -1; | return -1; |
| } else | } else |
| idx = BucketIndex(size); | idx = BucketIndex(size); |