This file contains a utility class that appends sprintf'ed output to a dynamically allocated buffer while growing the buffer if necessary.
It is still conceivable that the sprintf will generate a long enough string that will cause a buffer overflow. However, since the class is only used to render states into strings, and the margin allowed for the buffer is long enough, this cannot actually happen.
Implements a random number generating class. The algorithm is identical to that of the Microsoft C Run-Time Library (RTL), but the generator can be instantiated.
An optimised hash implementations. This hash maps keys to values. It stores the hash function values next to the keys, so two keys can be first compared with their hash values, before the costly full comparison is done. It also uses a secondary hash to speed up the detection of two keys with identical primary hash values.
Not all the functions of the hash Abstract Data Type (ADT) are implemented here. Only these that need to be used by Freecell Solver.
This module implements two functions - an advanced binary search one and a function to merge a small sorted array into a larger sorted array. It was used until the newer hash or balanced binary tree storage were implemented, and may still be used if FCS_STATE_STORAGE_INDIRECT or FCS_STACK_STORAGE_INDIRECT are specified. [1]
This module compactly allocates blocks of arbitrary length, usually used for dynamically allocated Freecell columns. The blocks are allocated one after the other inside malloc()'ed memory segments that are thus guaranteed to retain their position.
This module contains a class that implements a chopping of a string into arguments. This is done using a subset of the UNIX Bourne shell functionality. Namely:
A backslash (\) makes the next character an actual such character.
A newline or a white-space separates a word.
A backslash at the end of the line continues the processing.
Double quotes (") wrap an argument that may contain white-space.
A pound sign (#) makes a comment that extends to the end of the line.
The code itself is very spaghetti-like but it is working.
This module implements a priority queue as a binary heap. It is derived from Justin Heyes-Jones C++ code which he has kindly donated to Freecell Solver (while re-licensing it under the public domain). Since then, the code has been converted to ANSI C , modified and optimised.
This module is used by the Best-First-Search scan.
[1] It is no longer recommended to use a sorted array as a state or stack storage, as they are much slower than using a hash or a balanced binary tree, both in asymptotic complexity (O(n2))) and in average performance.