Array of Str instances

Web Site  Methods

 
Str::ConstructAt
Str::DestructAt
 
static void ConstructAt(Str* location, int count)
static void DestructAt(Str* location, int count)

These two static methods aid in constructing a number of Str instances thru a means other than operator new. They are very useful when working with a dynamically allocated array of strings.

See the following example:

   Str* AllocStrArray(int count)
{
ASSERT(sizeof(Str) == sizeof(LPCTSTR)); // Will always be true!
Str* mem = (Str*) malloc (sizeof(Str) * count);
Str::ConstructAt(mem, count);
return mem;
}

void FreeStrArray(Str* data, int count)
{
Str::DestructAt(data, count);
free(data);
}

The count parameter must always be greater than zero.  Also note that the size of the Str instance is always equal to the size of a pointer in the system (4 bytes on currently supported platforms).  This is an implementation detail that is important to the functioning of many features and is guaranteed to be preserved in future versions of the library.

See also: Constructors & utility