Stack.C


Category:
Scripts
C/C++
Requirements:
Seller:
Price:
-
System:
Rating:
4.5
License:

Description - Stack.C



Many times I wanted to have one or more stacks for the program I was working on. Sometimes I did without -- especially on Quick and Dirty utilities. At other times I cobbled up something that more or less seemed to work. Crashes were common ... So I decided to take the time to do something about it.This is the result. - The Stack system is based on dynamic arrays: automatically growing the stacks when needed. The growing is done in Steps of 16 items. This reduces the number of required memory reallocations (and therefore the number of allocation failures). - Stack shrinking is intentionally not implemented. - ItemSizes larger than 2kB are not supported: the minimum of initial StackItems per stack is currently 32. An assert (debug version) limits ItemSizes: = 2 Bytes. For large data items a separate `user` module is probably sensible. StackUnpop is added to take a look at info, especially size info so an appropriate amount of memory can be allocated by the user. - A certain amount of redundancy is provided to enable integrity checks for use in programs with `wild pointer` problems. - Compile with NDEBUG defined for a `production` version. Compile with NDEBUG _not_ defined for a debug version. - Some functions benefit by using the compilers optimizer. Especially `Common Sub-expression Optimizations`. - Some items should be unsigned in stead of int. Not a real problem. Detected by checking the appropriateness and ranges of types. - In some places an int is cast to unsigned, then tested for a `large` value including `Negative` values. This may be non-portable.



More in C/C++-Stack.C

Especially Compile Compile With Compile With Ndebug