record = dataset->data; head = &(dataset->data); /* keep records that match the criteria, otherwise delete them */ while(record != NULL) { if(atoi(record->data[0]) == 1008130) { head = &(record->next); record = record->next; } else { *head = record->next; clusterGIS_Free_record(record); record = *head; } }