patch from colinf for #2305 to use sizeof(Sample)