After thinking a bit more about it, I realized the stuff about the GPF is probably not correct. It would just copy garbage. As I think thru things, I try to document them so I (or someone else) won't come back later on and try to improve on the code without throughly thinking things thru. Based on your suggestion, I've added the following comments to my memoryFill() function.
void memoryFill( void* target, char* pattern, size_t ptrnlen, size_t numRepeats )
{
char* trgt = (char*)target; //for ease in pointer manipulation.
...
//
// If we KNEW that memcpy copied from the base of the src array to the base
// of the target array, we could write an EXTREMELY fast algorithm:
// memcpy( trgt, pattern, ptrnlen ); //put one copy at the base.
// memcpy( trgt+ptrnlen, trgt, ptrnlen*(numRepeats-1) ); //destructive copy the rest
// Conversely, if we KNEW that memcpy copied from the end of the src array
// to the end of the target array, we could write:
// memcpy( trgt+ptrnlen*(numRepeats-1) , pattern, ptrnlen ); //put one copy at the end.
// memcpy( trgt, trgt+ptrnlen, ptrnlen*(numRepeats-1) ); //destructive copy the rest
// However, the C standard distinctly says that memcpy can do it's copying
// in whatever order it wants. We CANNOT rely on any specific order.
//
...
}
David