Skip to content

Commit 1dda3d7

Browse files
committed
fine tuning
1 parent 702ca83 commit 1dda3d7

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

src/mmdata.h

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ void *poolFixedMalloc(long size /* bytes */);
322322
* the given size is allocated from the system. In any case, the header of the
323323
* \ref block is properly initialized. Exits program on out of memory
324324
* condition.
325-
* \param[in] size (in bytes) of the block, not including the block header.
325+
* \param[in] size (in bytes) of the block, not including the block header, but
326+
* including space for a terminal NULL.
326327
* \return a free and initialized block of memory with at least the requested
327328
* user space. Exit on out-of-memory
328329
*/
@@ -336,11 +337,14 @@ void *poolMalloc(long size /* bytes */);
336337
* added.
337338
* \param[in] ptr pointer to a \ref block.
338339
* \pre
339-
* all memory pointed to by \p ptr is considered free. This holds even if it
340-
* it is kept in \ref memUsedPool.
340+
* - \p ptr was previously allocated.
341+
* - all memory pointed to by \p ptr is considered free. This holds even if it
342+
* it is kept in \ref memUsedPool.
341343
* \post
342344
* - \ref poolTotalFree is updated
343345
* - Exit on out-of-memory (the \ref memFreePool overflows)
346+
* \attention never submit a \p ptr referring to memory not on the heap, like
347+
* NULL_PTRSTRING.
344348
*/
345349
void poolFree(void *ptr);
346350
/*!
@@ -410,7 +414,7 @@ long getFreeSpace(long max);
410414

411415
/* Fatal memory allocation error */
412416
/*!
413-
* \fn outOfMemory(const char *msg)
417+
* \fn void outOfMemory(const char *msg)
414418
* \brief exit after fatal memory allocation error.
415419
*
416420
* called when memory cannot be allocated, either because memory/address space
@@ -428,7 +432,7 @@ void outOfMemory(const char *msg);
428432

429433
/* Bug check error */
430434
/*!
431-
* \fn bug(int bugNum)
435+
* \fn void bug(int bugNum)
432436
*/
433437
void bug(int bugNum);
434438

@@ -707,21 +711,31 @@ temp_pntrString *pntrMakeTempAlloc(pntrString *s);
707711
/* String assignment - MUST be used to assign vstrings */
708712
/*!
709713
* \fn void pntrLet(pntrString **target, const pntrString *source)
714+
* Copies the \ref pntrString elements of \p source to the beginning of a
715+
* \ref block referenced by \p target. If necessary, the \p target block is
716+
* reallocated, and if it is, it gets twice the needed size to account for
717+
* future growing. If the \p target block is only partially used after copy it
718+
* is added to the \ref memUsedPool. If \p source is empty, the \p target is
719+
*
710720
* \param[in,out] target (not null) the address of a pointer pointing to the
711-
* first byte of a \ref block receiving the copied \p source.
721+
* first byte of a \ref block receiving the copied elements of \p source.
712722
* \param[in] source (not null) a pointer to the first \ref pntrString element
713723
* in a \ref block, to be copied from.
714724
* \pre
715725
* - source does not contain NULL pointer, but is terminated by one. This
716726
* NULL pointer is not part of the array, but must be present.
717-
* - the target \ref block does not contain used data.
727+
* - the target \ref block does not contain any valuable data.
718728
* \post
719729
* - the \ref block \p target points to is filled with a copy of
720730
* \ref pntrString elements \p source points to, padded with a terminal
721731
* NULL.
722-
* - Exit on out-of-memory
723732
* - due to a possible reallocation the pointer \p target points to may
724733
* change.
734+
* - updates \ref db3 and \ref poolTotalFree.
735+
* - Exit on out-of-memory
736+
* \bug If the \p target block is full after the copy operation, it is not
737+
* necessarily removed from the \ref memUsedPool, although other
738+
* functions like \ref addToUsedPool do not support this.
725739
*/
726740
void pntrLet(pntrString **target, const pntrString *source);
727741

@@ -751,9 +765,10 @@ temp_pntrString *pntrPSpace(long n);
751765
* dedicated to it.
752766
*
753767
* returns the number of **reserved** pointers in the array pointed to by \p s,
754-
* derived solely from administrative data in the surrounding \ref block. NULL
755-
* pointer in the array are included, a trailing one is not required to
756-
* determine the length.´
768+
* derived solely from administrative data in the surrounding \ref block. Thus,
769+
* the value is valid, even if data has not yet been transferred to the
770+
* reserved space, and the terminal NULL is not safely recognized. The returned
771+
* value excludes the space set aside for a terminal NULL.
757772
*
758773
* \attention This is not the capacity of the array.
759774
* \param[in] s points to a element 0 of a \ref pntrString embedded in a block

0 commit comments

Comments
 (0)