there was a 'memory leak' when the bits[] and data[] array were declared outside the function that used them. when moving these arrays in the function fixed the seg faults i kept getting.