Skip to content

Commit d7ebf77

Browse files
committed
better doc early phase of pntrString allocation
1 parent c58210d commit d7ebf77

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/mmdata.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2468,11 +2468,14 @@ pntrString *pntrTempAllocStack[M_MAX_ALLOC_STACK];
24682468
* \ref memFreePool.
24692469
* \param[in] size count of \ref pntrString entries. This value must include
24702470
* a terminal NULL pointer if needed.
2471-
* \return a pointer to the allocated \ref block, or NULL if deallocation only
2471+
* \return a pointer to the allocated \ref block, or NULL if deallocation
2472+
* requested
24722473
* \pre
24732474
* \p size ==0: all entries in from \ref pntrTempAllocStack from
24742475
* \ref g_pntrTempAllocStackStart do not contain relevant data any more.
24752476
* \post
2477+
* - \p size > 0: memory for \p size entries is reserved in the \ref block
2478+
* "block's" header, but the data is still random.
24762479
* - Exits on out-of-memory
24772480
* - updates \ref db2
24782481
*/

src/mmdata.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
/*E*/extern long db2;
5252
/*!
5353
* \var db3
54-
* \brief monitors the de/allocations of nmbrString and pntrString outside of
55-
* temporary arrays.
54+
* \brief monitors the de/allocations of nmbrString and \ref pntrString outside
55+
* of temporary arrays.
5656
*
5757
* The number of bytes held in blocks dedicated to global data. There exist
5858
* also temporary stacks, but they are not considered here. Useful to see
@@ -123,6 +123,12 @@ typedef long nmbrString; /* String of numbers */
123123
* tail of an array from a certain element on, an array terminates with a
124124
* null pointer. This type of usage forbids null pointer as ordinary elements,
125125
* and the terminal null pointer is not part of the data in the array.
126+
* \n
127+
* The length of a pntrString array is implicitely given by a terminal NULL
128+
* pointer. If this array is held in a \ref block, its size can also be
129+
* determined from its header's administrative data. Both values must be kept
130+
* synchronized. In early phases of memory allocation, when data wasn't
131+
* assigned yet, this need not hold.
126132
*
127133
* To summarize the usages of this type:
128134
* - If you want to resize the array/stack you need a pointer to element 0.
@@ -325,9 +331,11 @@ void *poolFixedMalloc(long size /* bytes */);
325331
* \ref block is properly initialized. Exits program on out of memory
326332
* condition.
327333
* \param[in] size (in bytes) of the block, not including the block header.
328-
* \return a \ref block with enough capacity for \p size bytes of data. The
329-
* data space is filled with random contents, but in the block header its
330-
* \p size is noted.´ Exit on out-of-memory
334+
* \return a \ref block with enough capacity for \p size bytes of data.
335+
* \post
336+
* - The \ref block "block's" header denotes \p size bytes are occupied, but
337+
* they yet contain random data.
338+
* - Exit on out-of-memory.
331339
*/
332340
void *poolMalloc(long size /* bytes */);
333341
/*!
@@ -339,7 +347,7 @@ void *poolMalloc(long size /* bytes */);
339347
* added.
340348
* \param[in] ptr pointer to a \ref block.
341349
* \pre
342-
* - \p ptr was previously dynamically allocated.
350+
* - \p ptr refers to dynamically allocated memory on the heap.
343351
* - all memory pointed to by \p ptr is considered free. This holds even if it
344352
* it is kept in \ref memUsedPool.
345353
* \post

0 commit comments

Comments
 (0)