Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
966cfac
doc cmdInput (1)
wlammen Mar 3, 2022
50bd232
copy preconditions of cmdInput to cmdInput1
wlammen Mar 3, 2022
4804d23
fix description of return in cmdInput
wlammen Mar 3, 2022
254c77c
document the role of CTRL-D in cmdInput
wlammen Mar 3, 2022
125f652
clarify some points
wlammen Mar 4, 2022
60c1181
better understand hyperlinking in doxygen
wlammen Mar 4, 2022
34533da
explain cmdIput1, next version
wlammen Mar 4, 2022
35e8952
explain cmdIput1, next version
wlammen Mar 4, 2022
e5e5cd2
explain cmdIput1, next version
wlammen Mar 4, 2022
83c4919
doc log file
wlammen Mar 4, 2022
39b356c
point out copy problems of pointers
wlammen Mar 4, 2022
1017b3d
doc addToUsedPool
wlammen Mar 4, 2022
da73b5c
fix incorrect usage of memUsedPool in case of full blocks
wlammen Mar 4, 2022
67fa533
clarify post cond. of addToUsedPool
wlammen Mar 4, 2022
ac1dc02
fix description of memUsedPool
wlammen Mar 4, 2022
49af905
doc poolFree
wlammen Mar 5, 2022
0fcfc29
add pre post conditions
wlammen Mar 5, 2022
7beeb0e
doc poolMalloc and others
wlammen Mar 5, 2022
61a4c78
fix doc of getPoolStats
wlammen Mar 5, 2022
702ca83
doc pntrTempAlloc
wlammen Mar 5, 2022
1dda3d7
fine tuning
wlammen Mar 5, 2022
023eda4
be more precise with temp_pntrString
wlammen Mar 5, 2022
ff8f9d1
improve doc of poolMalloc
wlammen Mar 5, 2022
c58210d
do the best to ref to bug()
wlammen Mar 6, 2022
d7ebf77
better doc early phase of pntrString allocation
wlammen Mar 6, 2022
bc48424
describe temporary stacks in more detail
wlammen Mar 6, 2022
0f3adf2
extend description of pntrTempAllocStack
wlammen Mar 6, 2022
9149544
improve doc of pntrLet
wlammen Mar 6, 2022
42fa455
improve doc of pntrLet
wlammen Mar 6, 2022
515fec4
fix doc of let
wlammen Mar 6, 2022
8ba2356
fix spelling errors
wlammen Mar 6, 2022
733456f
doc pntrAddElement
wlammen Mar 6, 2022
7f66022
doc submit mode in cmdInput1
wlammen Mar 6, 2022
251d2b5
finished doc of cmdInput1
wlammen Mar 6, 2022
677d6a7
the final edits were not saved, so here they are
wlammen Mar 6, 2022
d4d1faa
fix review issues
wlammen Mar 7, 2022
3021161
rm a LF
wlammen Mar 7, 2022
c9b3a49
add pre to pntrAddElement
wlammen Mar 7, 2022
91b9cd6
rm more unnecessary LF
wlammen Mar 7, 2022
80af6db
resolve merge conflicts
wlammen Mar 7, 2022
ff2ba42
fix dangling conflict marker
wlammen Mar 7, 2022
e9d586b
fix indentation
wlammen Mar 7, 2022
da19baf
css for customizing p tags
wlammen Mar 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/mmcmdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ extern flag g_commandEcho; /*!< Echo full command */
/*!
* \brief `MEMORY_STATUS` option: Always show memory
*
* Indicates whether the user has turned MEMORY_STATUS on.
*
* If the user issues SET MEMORY_STATUS ON this \ref flag is set to 1. It is
* reset to 0 again on a SET MEMORY_STATUS OFF command. When 1, certain
* memory de/allocations are monitored - see \ref db3.
Expand Down
64 changes: 37 additions & 27 deletions src/mmdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ typedef nmbrString temp_nmbrString;
* dynamically allocated memory on the heap. Special commands support
* dependency tracking and free all pointers on and after a particular one in
* such a stack.
=======
* These elements are pushed onto and popped off a \ref stack
* "stack of temporary data". Special commands can free all pointers on and
* after a particular one in such a stack.
>>>>>>> upstream/master
*/
typedef pntrString temp_pntrString;

Expand Down Expand Up @@ -463,7 +468,9 @@ extern struct nullNmbrStruct g_NmbrNull;

/*!
* \struct nullPntrStruct
* describing a \ref block of \ref pntrString containing only the null
* \brief Null pntrString -- NULL flags the end of a pntrString
*
* Describes a \ref block of \ref pntrString containing only the null
* pointer. Besides this pointer it is accompanied with a header containing
* the hidden administrative values of such \ref block "block".
*
Expand All @@ -474,30 +481,31 @@ extern struct nullNmbrStruct g_NmbrNull;
* void*. In fact there might be **no** integer type matching a pointer in size.
*/
struct nullPntrStruct {
/*!
* An instance of a nullPntrStruct is always standalone and never part of a
* larger pool. Indicated by the fixed value -1.
*/
long poolLoc;
/*!
* allocated size of the memory block containing the \ref pntrString,
* excluding any hidden administrative data.
* Note: this is the number of bytes, not elements! Fixed to the size of a
* single void* instance.
*/
long allocSize;
/*!
* currently used size of the memory block containing the \ref pntrString,
* excluding any hidden administrative data.
* Note: this is the number of bytes, not elements! Fixed to the size of a
* single pointer element.
*/
long actualSize;
/*!
* memory for a single void* instance, set and fixed to the null pointer.
* A null marks the end of the array.
*/
pntrString nullElement; };
/*!
* An instance of a nullPntrStruct is always standalone and never part of a
* larger pool. Indicated by the fixed value -1.
*/
long poolLoc;
/*!
* allocated size of the memory block containing the \ref pntrString,
* excluding any hidden administrative data.
* Note: this is the number of bytes, not elements! Fixed to the size of a
* single void* instance.
*/
long allocSize;
/*!
* currently used size of the memory block containing the \ref pntrString,
* excluding any hidden administrative data.
* Note: this is the number of bytes, not elements! Fixed to the size of a
* single pointer element.
*/
long actualSize;
/*!
* memory for a single void* instance, set and fixed to the null pointer.
* A null marks the end of the array.
*/
pntrString nullElement;
};
/*!
* \var g_PntrNull
* Global instance of a memory block structured like a
Expand Down Expand Up @@ -743,9 +751,10 @@ temp_pntrString *pntrMakeTempAlloc(pntrString *s);
/**************************************************/


/* String assignment - MUST be used to assign vstrings */
/*!
* \fn void pntrLet(pntrString **target, const pntrString *source)
* String assignment - MUST be used to assign vstrings.
*
* Copies the \ref pntrString elements of \p source to the beginning of a
* \ref block referenced by \p target. If necessary, the \p target block is
* reallocated, and if it is, it gets twice the needed size to account for
Expand Down Expand Up @@ -852,9 +861,10 @@ long pntrRevInstr(long start_position, const pntrString *string1,
/*! 1 if strings are equal, 0 otherwise */
flag pntrEq(const pntrString *sout, const pntrString *sin);

/* Add a single null string element to a pntrString - faster than pntrCat */
/*!
* \fn temp_pntrString *pntrAddElement(const pntrString *g)
* Add a single null string element to a pntrString - faster than pntrCat
*
* \param[in] g points to the first element of a NULL terminated array in a
* \ref block. It is assumed it is an array of pointer to \ref vstring.
* \return a copy of \p g, the terminal NULL replaced with a \ref vstring ""
Expand Down
9 changes: 5 additions & 4 deletions src/mminou.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extern FILE *g_listFile_fp;

/*!
* \var g_outputToString
*
* Global variable redirecting the output of the function print2 from the
* console ( = 0) to a string ( = 1). Initialized to 0 on program start.
*/
Expand Down Expand Up @@ -158,10 +159,10 @@ void printLongLine(const char *line, const char *startNextLine, const char *brea
* This routine interprets some input without returning it to the caller under
* following two conditions:
*
* 1. If scrolling is enabled, a line consisting of a single character b or B
* indicates the user wants to scroll back through saved pages of output.
* If it can be served, it is handled within this routine, else the b or B is
* returned as user input.
* 1. If scrolling is enabled, the input is interpreted. A line consisting of
* a single character b or B indicates the user wants to scroll back through
* saved pages of output. This is handled within this routine, as often as
* requested and possible.
*
* 2. The user hits ENTER only while prompted in top level context. The empty
* line is not returned.
Expand Down
37 changes: 37 additions & 0 deletions src/mmvstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,43 @@ typedef char* vstring;
* construction of a final \ref vstring, it is allocated on the heap as usual.
*
* If returned by a function, it is already pushed on the \ref tempAllocStack.
*
* A `temp_vstring` should never be used as the first argument of a `let`.
* This code is INCORRECT:
*
* temp_vstring foo = left("foobar", 3);
* let(&foo, "bar"); // this will cause a double free
*
* It is okay (and quite common) to use a temp_vstring as the second argument,
* however. It is best not to hold on to the value, though, because the `let`
* will free it. This code is INCORRECT:
*
* vstring_def(x);
* temp_vstring foobar = cat("foo", "bar");
* let(&x, foobar); // frees foobar
* let(&x, foobar); // dangling reference
*
* There is a converse problem when `temp_vstring`s are used without `let`:
*
* for (int i = 0; i < 100000; i++) {
* vstring_def(x);
* if (strlen(space(i)) == 99999) break;
* }
*
* We don't need to deallocate the string returned by `space()` directly,
* because it returns a `temp_vstring`, but because there is no `let` in
* this function, we end up allocating a bunch of temporaries and
* effectively get a memory leak. (There is space for about 100
* temporaries so this loop will cause a crash.) To solve this problem,
* we can either use a dummy `let()` statement in the loop, or call
* `freeTempAlloc` directly:
*
* for (int i = 0; i < 100000; i++) {
* vstring_def(x);
* if (strlen(space(i)) == 99999) break;
* freeTempAlloc();
* }
*
*/
typedef vstring temp_vstring;

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.