Rather than magic numbers (4, 7) it might be better to check if size == 0.  As you have it above, g_MemorySize is always 0 at that point...

-[Unknown]