tango.core.tools.WinStackTrace

Stacktracing
Inclusion of this module activates traced exceptions using the tango own tracers if possible.

License:

Tango License, Apache 2.0

Author:

Tomasz Stachowiak (h3r3tic)
void alloc(T, intT)(ref T array, intT numItems, bool init = true) #
Allocate the array using malloc

Params:

arrayThe array which will be resized.
numItemsNumber of items to be allocated in the array.
initWhether to init the allocated items to their default values or not.

Examples:

1
2
int[] foo;
foo.alloc(20);

Remarks:

The array must be null and empty for this function to succeed. The rationale behind this is that the coder should state his decision clearly. This will help and has already helped to spot many intricate bugs.
T clone(T)(T array) #
Clone the given array. The result is allocated using alloc() and copied piecewise from the param. Then it's returned
void realloc(T, intT)(ref T array, intT numItems, bool init = true) #
Realloc the contents of an array.

Params:

arrayThe array which will be resized.
numItemsThe new size for the array.
initWhether to init the newly allocated items to their default values or not.

Examples:

1
2
3
int[] foo;
foo.alloc(20);
foo.realloc(10);        // <--
void free(T)(ref T array) #
Deallocate an array allocated with alloc().
void append(T, I)(ref T array, I elem, uint* realLength = null) #
Append an item to an array. Optionally keep track of an external 'real length', while doing squared reallocation of the array.

Params:

arrayThe array to append the item to.
elemThe new item to be appended.
realLengthThe optional external 'real length'.

Remarks:

If realLength isn't null, the array is not resized by one, but allocated in a std::vector manner. The array's length becomes it's capacity, while 'realLength' is the number of items in the array.

Examples:

1
2
3
4
5
6
7
8
uint barLen = 0;
int[] bar;
append(bar, 10, &barLen);
append(bar, 20, &barLen);
append(bar, 30, &barLen);
append(bar, 40, &barLen);
assert (bar.length == 16);
assert (barLen == 4);