diff options
Diffstat (limited to 'src/microhttpd/memorypool.c')
-rw-r--r-- | src/microhttpd/memorypool.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c index 037cbf57..7cc4f286 100644 --- a/src/microhttpd/memorypool.c +++ b/src/microhttpd/memorypool.c | |||
@@ -151,6 +151,19 @@ MHD_pool_destroy (struct MemoryPool *pool) | |||
151 | 151 | ||
152 | 152 | ||
153 | /** | 153 | /** |
154 | * Check how much memory is left in the @a pool | ||
155 | * | ||
156 | * @param pool pool to check | ||
157 | * @return number of bytes still available in @a pool | ||
158 | */ | ||
159 | size_t | ||
160 | MHD_pool_get_free (struct MemoryPool *pool) | ||
161 | { | ||
162 | return (pool->end - pool->pos); | ||
163 | } | ||
164 | |||
165 | |||
166 | /** | ||
154 | * Allocate size bytes from the pool. | 167 | * Allocate size bytes from the pool. |
155 | * | 168 | * |
156 | * @param pool memory pool to use for the operation | 169 | * @param pool memory pool to use for the operation |
@@ -163,7 +176,8 @@ MHD_pool_destroy (struct MemoryPool *pool) | |||
163 | */ | 176 | */ |
164 | void * | 177 | void * |
165 | MHD_pool_allocate (struct MemoryPool *pool, | 178 | MHD_pool_allocate (struct MemoryPool *pool, |
166 | size_t size, int from_end) | 179 | size_t size, |
180 | int from_end) | ||
167 | { | 181 | { |
168 | void *ret; | 182 | void *ret; |
169 | size_t asize; | 183 | size_t asize; |
@@ -171,7 +185,8 @@ MHD_pool_allocate (struct MemoryPool *pool, | |||
171 | asize = ROUND_TO_ALIGN (size); | 185 | asize = ROUND_TO_ALIGN (size); |
172 | if ( (0 == asize) && (0 != size) ) | 186 | if ( (0 == asize) && (0 != size) ) |
173 | return NULL; /* size too close to SIZE_MAX */ | 187 | return NULL; /* size too close to SIZE_MAX */ |
174 | if ((pool->pos + asize > pool->end) || (pool->pos + asize < pool->pos)) | 188 | if ( (pool->pos + asize > pool->end) || |
189 | (pool->pos + asize < pool->pos)) | ||
175 | return NULL; | 190 | return NULL; |
176 | if (from_end == MHD_YES) | 191 | if (from_end == MHD_YES) |
177 | { | 192 | { |