<commit_before>/*
 * Copyright (C) 2013 <NAME> (<EMAIL>)
 * See COPYING file for copying conditions
 */

#include "DeviceList.h"
#include "Device.h"

void setDeviceList(JNIEnv* env, libusb_device** list, int size, jobject object)
{
    SET_POINTER(env, list, object, "deviceListPointer");

    jclass cls = (*env)->GetObjectClass(env, object);
    jfieldID field = (*env)->GetFieldID(env, cls, "size", "I");
    (*env)->SetIntField(env, object, field, size);
}

libusb_device** unwrapDeviceList(JNIEnv* env, jobject list)
{
    UNWRAP_POINTER(env, list, libusb_device**, "deviceListPointer");
}

void resetDeviceList(JNIEnv* env, jobject obj)
{
    RESET_POINTER(env, obj, "deviceListPointer");
}

/**<commit_msg>Set size to zero on reset. Else getting the size is incorrect, and later when checking in get() it would pass the check and you'd access a NULL ptr.<commit_after>/*
 * Copyright (C) 2013 <NAME> (<EMAIL>)
 * See COPYING file for copying conditions
 */

#include "DeviceList.h"
#include "Device.h"

void setDeviceList(JNIEnv* env, libusb_device** list, int size, jobject object)
{
    SET_POINTER(env, list, object, "deviceListPointer");

    jclass cls = (*env)->GetObjectClass(env, object);
    jfieldID field = (*env)->GetFieldID(env, cls, "size", "I");
    (*env)->SetIntField(env, object, field, size);
}

libusb_device** unwrapDeviceList(JNIEnv* env, jobject list)
{
    UNWRAP_POINTER(env, list, libusb_device**, "deviceListPointer");
}

void resetDeviceList(JNIEnv* env, jobject obj)
{
    RESET_POINTER(env, obj, "deviceListPointer");

    // Reset size to zero too.
    jclass cls = (*env)->GetObjectClass(env, obj);
    jfieldID field = (*env)->GetFieldID(env, cls, "size", "I");
    (*env)->SetIntField(env, object, field, 0);
}

/**
{'fraction_non_alphanumeric': 0.1560364464692483, 'fraction_numerical': 0.005125284738041002, 'mean_word_length': 4.8566666666666665, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 16, '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': '746456', 'n_tokens_mistral': 616, 'n_tokens_neox': 601, 'n_words': 167}