Skip to content

Commit 0fcfc29

Browse files
committed
add pre post conditions
1 parent 49af905 commit 0fcfc29

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/mmdata.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,31 +316,35 @@ void *poolMalloc(long size /* bytes */);
316316
* \ref MEM_POOL_GROW. If this fails, an error is created, else \p ptr is
317317
* added.
318318
* \param[in] ptr pointer to a \ref block.
319+
* \pre
320+
* all memory pointed to by \p ptr is considered free.
321+
* \post
322+
* \ref poolTotalFree is updated
319323
* \bug calls outOfMemory, that can stack up endlessly
320324
*/
321325
void poolFree(void *ptr);
322326
/*!
323327
* \fn addToUsedPool(void *ptr)
324328
* \brief announces a block with free capacity for further allocation
325329
*
330+
* This function temporarily freezes the usage of a block for an old client, and
331+
* allows temporary reallocation of the free capacity to a new client.
332+
* \n
326333
* The program maintains pools of memory blocks with free capacity. In case of
327334
* demand such a \ref block can temporarily allocate this capacity for new
328335
* usage. Of course two (or more) clients share different parts of the same
329336
* \ref block then, so a newer client must complete its usage before the old
330337
* one resumes operation and may want to extend its usage of the \ref block.
331338
* \n
332-
* This function temporarily freezes the usage of a block for an old client, and
333-
* allows temporary reallocation of the free capacity to a new client.
334-
* \n
335339
* Before \p ptr is added to \ref memUsedPool, the pool size is checked and
336340
* increased by \ref MEM_POOL_GROW if full. This may lead to out-of-memory
337341
* \ref bug "bugs". But if \p prt is added to the end of the \ref memUsedPool,
338342
* \ref poolTotalFree is updated.
339343
* \param[in] ptr pointer to a \ref block.
340344
* \pre
341-
* the block is \ref fragmentation "fragmented" (contains unused pointers)
342-
* If this condition is violated \ref bug is called and the function returns
343-
* without further action.
345+
* the block is \ref fragmentation "fragmented" (contains unused memory)
346+
* If it is full \ref bug is called and the function returns without further
347+
* action.
344348
* \post
345349
* - \ref poolTotalFree is the current free space in bytes in both pools.
346350
* - A full \ref block is not added to \ref memUsedPool by this function.

0 commit comments

Comments
 (0)