box = GEOSWKTReader_read(reader, "POLYGON((-112.0859375 33.4349975585938,-112.0859375 33.4675445556641,-112.059799194336 33.4675445556641,-112.059799194336 33.4349975585938,-112.0859375 33.4349975585938))"); record = dataset->data; head = &(dataset->data); /* keep records that match the criteria, otherwise delete them */ while(record != NULL) { char intersects; intersects = GEOSIntersects(record->geometry, box); if(intersects == 1) { /* record overlaps with box */ head = &(record->next); record = record->next; } else { /* no overlap */ *head = record->next; clusterGIS_Free_record(record); record = *head; } }