<commit_before>use libloading;
use sputnikvm::{SputnikVM};
use serde_json::{Value, Error};
use std::io::{BufReader, Write, stdout};



pub fn test_ffi_transaction(name: &str, v: &Value, debug: bool, sputnikvm_path: &str) {
    let mut ffi = FFI(libloading::Library::new(sputnikvm_path).unwrap_or_else(|error| panic!("{}",error)));
    println!("Testing {} ... ", name);
    if debug {
        print!("\n");
    }
    stdout().flush();

    let svm = ffi.sputnikvm_new(v);
    // ffi.sputnikvm_free(svm);
}

struct FFI(libloading::Library);

impl FFI {
    fn sputnikvm_new(&self, v: &Value) {
        unsafe {
            let f = self.0.get::<fn(v: &Value)> (
                b"sputnikvm_new\0"
            ).unwrap();
            f(v)
        }
    }
    fn sputnikvm_free(&self, svm: *mut SputnikVM) {
        unsafe {
            let f = self.0.get::<fn(svm: *mut SputnikVM)> (
                b"sputnikvm_free\0"
            ).unwrap();
            f(svm)
        }
    }
}
<commit_msg>Problem: vm wasn't firing<commit_after>use libloading;
use sputnikvm::{SputnikVM};
use serde_json::{Value, Error};
use std::io::{BufReader, Write, stdout};

pub fn test_ffi_transaction(name: &str, v: &Value, debug: bool, sputnikvm_path: &str) {
    let mut ffi = FFI(libloading::Library::new(sputnikvm_path).unwrap_or_else(|error| panic!("{}",error)));
    println!("Testing {} ... ", name);
    if debug {
        print!("\n");
    }
    stdout().flush();

    let svm = ffi.sputnikvm_new(v);
    ffi.sputnikvm_fire(svm);
    ffi.sputnikvm_free(svm);
}

struct FFI(libloading::Library);

impl FFI {
    fn sputnikvm_new(&self, v: &Value) -> *mut SputnikVM {
        unsafe {
            let f = self.0.get::<fn(v: &Value) -> *mut SputnikVM > (
                b"sputnikvm_new\0"
            ).unwrap();
            f(v)
        }
    }
    fn sputnikvm_fire(&self, svm: *mut SputnikVM) {
        unsafe {
            let f = self.0.get::<fn(svm: *mut SputnikVM)> (
                b"sputnikvm_fire\0"
            ).unwrap();
            f(svm)
        }
    }
    fn sputnikvm_free(&self, svm: *mut SputnikVM) {
        unsafe {
            let f = self.0.get::<fn(svm: *mut SputnikVM)> (
                b"sputnikvm_free\0"
            ).unwrap();
            f(svm)
        }
    }
}

{'fraction_non_alphanumeric': 0.16776460254721123, 'fraction_numerical': 0.004391743522178305, 'mean_word_length': 2.1727019498607243, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4301111', 'n_tokens_mistral': 858, 'n_tokens_neox': 864, 'n_words': 154}