Sha256: f18aa417f8374d26873643bceaf92ba57259c0f5ab3b2a3ffb8c4d366ebc0613
Contents?: true
Size: 1.06 KB
Versions: 4
Compression:
Stored size: 1.06 KB
Contents
/* Copyright (c) 2024 Julian Benda * * This file is part of inkCPP which is released under MIT license. * See file LICENSE.txt or go to * https://github.com/JBenda/inkcpp for full license details. */ #include "functions.h" namespace ink::runtime::internal { functions::functions() : _list(nullptr) , _last(nullptr) { } functions::~functions() { // clean list while (_list) { entry* toDelete = _list; _list = _list->next; // delete both value and entry delete toDelete->value; delete toDelete; } _list = _last = nullptr; } void functions::add(hash_t name, function_base* func) { entry* current = new entry; current->name = name; current->value = func; current->next = nullptr; if (_list == nullptr) { _list = _last = current; } else { _last->next = current; _last = current; } } function_base* functions::find(hash_t name) { // find entry entry* iter = _list; while (iter != nullptr && iter->name != name) iter = iter->next; return iter == nullptr ? nullptr : iter->value; } } // namespace ink::runtime::internal
Version data entries
4 entries across 4 versions & 1 rubygems