F_MODE_*: changed values
The F_MODE_AS and F_MODE_AD flags do not index the <prop> array,
in contrast to the other F_* entries, but blocked the next
possible index in this array. Therefore changed the numbering to
negative numbers that will never index an array.
Also use a symbolic constant for the length of the array <props>
and use it to allocate it.
Change-Id: I71e487515ef9851c5f12bf899c285b7fb1da3a59
diff --git a/std/thing/properties.c b/std/thing/properties.c
index d289de1..b9b2372 100644
--- a/std/thing/properties.c
+++ b/std/thing/properties.c
@@ -25,12 +25,12 @@
#include "/secure/wizlevels.h"
// the mapping where the actual properties are stored. Direct initialization.
-// Indexed with F_VALUE, F_MODE, F_SET_METHOD and F_QUERY_METHOD
-// F_MODE, F_SET_METHOD and F_QUERY_METHOD are usually 'sparse' (i.e. there is
-// no entry for most properties), therefore it is more memory-efficient to
-// store them like this than in one mapping, although it requires more
-// mapping lookups.
-private nosave mapping *prop = ({ ([]), ([]), ([]), ([]) });
+// Indexed with F_VALUE, F_MODE, F_SET_METHOD, F_QUERY_METHOD, F_VALIDATOR
+// F_MODE, F_SET_METHOD, F_QUERY_METHOD and F_VALIDATOR are usually 'sparse'
+// (i.e. there is no entry for most properties), therefore it is more
+// memory-efficient to store them like this than in one mapping, although it
+// requires more mapping lookups.
+private nosave mapping *prop = allocate(F_PROP_ENTRIES, ([]));
// the mapping that is used for saving. During save_object/restore_object it
// contains the properties with SAVE flag.
@@ -319,7 +319,7 @@
// nur vom Objekt selber manipuliert werden
if (same_object||!(prop[F_MODE][names[j]] & (PROTECTED|SECURED)) )
{
- i=4;
+ i=F_PROP_ENTRIES;
while(i--)
{
if(props[names[j],i])
@@ -343,11 +343,11 @@
int i, j;
string *names;
- props = m_allocate( 0, 4 );
+ props = m_allocate( sizeof(prop[F_VALUE]), F_PROP_ENTRIES );
if (pointerp(prop))
{
- i=4;
+ i=F_PROP_ENTRIES;
while(i--)
{
names = m_indices(prop[i]);
@@ -364,7 +364,7 @@
if ( pointerp(prop) )
return(deep_copy(prop));
else
- return ({ ([]),([]),([]),([]) });
+ return allocate(F_PROP_ENTRIES, ([]));
}