Pointer problems; cvCvtSeqToArray throws Null Pointer

Hi there,
I have been having a problem with cvCvtSeqToArray - I expect it is something
to do with my pointers and not freeing memory correctly, but I haven't been
able to work it out yet. The problem is amongst quite a large program so I
will paste only the relevant code;

In my main class I create a 'feature' item feats which is passed into
another class;

int main(int argc, char **argv) {
struct feature* feat;

while(keyPressed != 'q') {
noOfFeat = sift_features(image,&feat);

free(feat); //Should this be here?
}
}

In method sift_features;

int sift_features(IplImage* img, struct feature** feat) {
CvSeq* features;
CvMemStorage* storage;

features = create_features(img, storage);

n = features->total;

*feat = (feature*)calloc( n, sizeof(struct feature));
*feat = (feature*)cvCvtSeqToArray( features, *feat, CV_WHOLE_SEQ ); //
THROWS ERROR HERE

return n;
}

Here is the error message;
OpenCV Error: Null pointer () in cvCvtSeqToArray, file
/build/buildd/opencv-2.1.0/src/cxcore/cxdatastructs.cpp, line 548
terminate called after throwing an instance of 'cv::Exception'
what(): /build/buildd/opencv-2.1.0/src/cxcore/cxdatastructs.cpp:548:
error: (-27) in function cvCvtSeqToArray
Aborted

I know that features is being created correctly, as I have checked n (the
number of features) and popped items off successfully, so I'm sure it's
something to do with my feat. Any help would be greatly appreciated!!

Thanks
I believe this is a problem with pointers, which I'm a bit rusty on, so even if you don't know much about openCV your input/thoughts would be greatly appreciated!!

Thanks
Topic archived. No new replies allowed.