<commit_before>
#include "ObjectStore.h"
#include "Configuration.h"

ObjectStore::ObjectStore()
{
  memset(this->functions, '\0', 10);
  this->first = NULL;
  this->last = NULL;
  this->basicObjectCount = 0;
}

void ObjectStore::addObject(BasicObject* bo)
{
  ObjectStoreNode* node = new ObjectStoreNode();
  node->prev = this->last;
  node->next = NULL;
  node->object = bo;
  if (this->first == NULL) {
    this->first = node;
  } else {
    this->last->next = node;
  }
  this->last = node;
  this->basicObjectCount++;
}

void ObjectStore::updateObjects()
{
  for (ObjectStoreNode* node = this->first; node != NULL; node = node->next)
  {
    node->object->update();
  }
}

void ObjectStore::handleOrder(String objectName, byte orderVec[], long orderVecLen)
{
  for (ObjectStoreNode* node = this->first; node != NULL; node = node->next)
  {
    if (node->object->hasName(objectName))
    {
      node->object->handleOrder(orderVec, orderVecLen);
    }
  }
}

void ObjectStore::loadSaved()
{
  byte sd[200];
  byte sdLength = Configuration::getSD(sd, 200);
  byte currPos = 0;
  int objNum = 0;
  while (sdLength > currPos)
  {
    byte sdObjectLength = sd[currPos];
    byte sdObjectType = sd[currPos + 1];
    if (sdObjectType < 10) {

      BasicObject* bo = this->functions[sdObjectType]();
      bo->init(String("Points " + String(objNum + 1)), sd + (currPos + 2), sdObjectLength - 1);
      ObjectStore::getInstance().addObject(bo);
    }
    currPos += sd[currPos] + 1;
    objNum++;
  }
}

void ObjectStore::registerType(int typeId, initObjectFunction fun)
{
  this->functions[typeId] = fun;
}
<commit_msg>Fixed potential NULL pointer issue<commit_after>
#include "ObjectStore.h"
#include "Configuration.h"

ObjectStore::ObjectStore()
{
  memset(this->functions, '\0', 10);
  this->first = NULL;
  this->last = NULL;
  this->basicObjectCount = 0;
}

void ObjectStore::addObject(BasicObject* bo)
{
  ObjectStoreNode* node = new ObjectStoreNode();
  node->prev = this->last;
  node->next = NULL;
  node->object = bo;
  if (this->first == NULL) {
    this->first = node;
  } else {
    this->last->next = node;
  }
  this->last = node;
  this->basicObjectCount++;
}

void ObjectStore::updateObjects()
{
  for (ObjectStoreNode* node = this->first; node != NULL; node = node->next)
  {
    node->object->update();
  }
}

void ObjectStore::handleOrder(String objectName, byte orderVec[], long orderVecLen)
{
  for (ObjectStoreNode* node = this->first; node != NULL; node = node->next)
  {
    if (node->object->hasName(objectName))
    {
      node->object->handleOrder(orderVec, orderVecLen);
    }
  }
}

void ObjectStore::loadSaved()
{
  byte sd[200];
  byte sdLength = Configuration::getSD(sd, 200);
  byte currPos = 0;
  int objNum = 0;
  while (sdLength > currPos)
  {
    byte sdObjectLength = sd[currPos];
    byte sdObjectType = sd[currPos + 1];
    if (sdObjectType < 10 && this.functions[sdObjectType] != NULL) {
      BasicObject* bo = this->functions[sdObjectType]();
      bo->init(String("Points " + String(objNum + 1)), sd + (currPos + 2), sdObjectLength - 1);
      ObjectStore::getInstance().addObject(bo);
    }
    currPos += sd[currPos] + 1;
    objNum++;
  }
}

void ObjectStore::registerType(int typeId, initObjectFunction fun)
{
  this->functions[typeId] = fun;
}

{'fraction_non_alphanumeric': 0.16190765492102066, 'fraction_numerical': 0.011543134872417983, 'mean_word_length': 3.7110157367668095, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 59, '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': '5768159', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1123, 'n_words': 244}