<commit_before>#include "wakaama_object_utils.h"
#include "wakaama/liblwm2m.h"

#include <stdarg.h>
#include <string.h>

static lwm2m_object_res_item_t* prv_find_ressource(lwm2m_object_meta_information_t* metaP, uint16_t id) {
    return &metaP->ressources[id];
}

// For opaque fields we always expect to find a size_t member with the length information
// right after the data pointer.
#define OPAQUE_SIZE_MEMBER_P(memberP) ((size_t*)((char*)memberP+sizeof(void*)))

int lwm2m_object_prepare_full_response(lwm2m_data_t ** dataArrayP, lwm2m_object_meta_information_t* metaP)
{
    *dataArrayP = lwm2m_data_new(metaP->ressources_len);
    if (*dataArrayP == NULL) return -1;
    int readable = 0;<commit_msg>Fix prv_find_ressource for sparse ressources.<commit_after>#include "wakaama_object_utils.h"
#include "wakaama/liblwm2m.h"

#include <stdarg.h>
#include <string.h>

static lwm2m_object_res_item_t* prv_find_ressource(lwm2m_object_meta_information_t* metaP, uint16_t id) {
    for (int index = 0; index < metaP->ressources_len; index++) {
        if (metaP->ressources[index].ressource_id == id) {
            return &metaP->ressources[index];
        }
    }
    
    return NULL;
}

// For opaque fields we always expect to find a size_t member with the length information
// right after the data pointer.
#define OPAQUE_SIZE_MEMBER_P(memberP) ((size_t*)((char*)memberP+sizeof(void*)))

int lwm2m_object_prepare_full_response(lwm2m_data_t ** dataArrayP, lwm2m_object_meta_information_t* metaP)
{
    *dataArrayP = lwm2m_data_new(metaP->ressources_len);
    if (*dataArrayP == NULL) return -1;
    int readable = 0;
{'fraction_non_alphanumeric': 0.11159062885326756, 'fraction_numerical': 0.014180024660912454, 'mean_word_length': 5.2664092664092665, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 13, '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': '2458223', 'n_tokens_mistral': 612, 'n_tokens_neox': 605, 'n_words': 123}