mirror of
https://github.com/pevans/erc-c.git
synced 2024-12-13 15:33:17 +00:00
Allow mutability if in testing
This commit is contained in:
parent
4e0892dc86
commit
5e7492abdf
15
src/vm_di.c
15
src/vm_di.c
@ -10,6 +10,7 @@
|
||||
* a value for a DI entry, it cannot be changed.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "log.h"
|
||||
@ -22,15 +23,25 @@
|
||||
*/
|
||||
static void *di_table[VM_DI_SIZE];
|
||||
|
||||
#ifdef TESTING
|
||||
static bool di_mutable = true;
|
||||
#else
|
||||
static bool di_mutable = false;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set the di table entry `ent` to `val`. If there is a _previous_
|
||||
* value assigned to ent, then this returns ERR_INVALID, and no
|
||||
* further assignment is allowed.
|
||||
* further assignment is allowed.
|
||||
*
|
||||
* NOTE: in testing, we _do_ allow multiple assignments to entries, so
|
||||
* as to make it easier to tear down and rebuild machines/cpus/etc.
|
||||
* between tests.
|
||||
*/
|
||||
int
|
||||
vm_di_set(int ent, void *val)
|
||||
{
|
||||
if (di_table[ent] != NULL) {
|
||||
if (di_table[ent] != NULL && !di_mutable) {
|
||||
return ERR_INVALID;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user