Thx for the help XD
But no ... the vot should be in range all the time.
The program doesn't crash.
Apparently memory size just messes up some values. XD
The funny thing is:
The pointers from the alloc functions are actually working, I can read all the values from memory just fine and even write without problems.
It's the fact that I can't get the memory size that messes things up for my system XD.
One solution I considered is writing my own size into the memory ( I already did that for VObject and VObject List, but because of the buffers ).
Actually the more I think about it the more I think the actual problems lies within "MEMORY SIZE".
I searched for the error endless hours now ... and I also tried different other methods ... but since I'm going for performance there aren't many.
This is the complete functions:
FUNCTION xvobject_text_make(Text$ AS STRING)
LOCAL returnval AS INTEGER
LOCAL vot AS INTEGER
LOCAL Textcount AS INTEGER
LOCAL Size AS INTEGER
LOCAL sSize AS INTEGER
LOCAL Ptr AS INTEGER
LOCAL TextPtr AS INTEGER
TextPtr = GET STRING PTR(Text$)
returnval = xvobject_text_get_indexs(TextPtr)
IF returnval = -1
vot = xvobject_text_id_generate()
Size = FAST LEN(Text$) + 4
vobject_text(vot) = ALLOC ZEROED(Size)
sSize = MEMORY SIZE(vobject_text(vot))
IF sSize <> Size
PRINT "String:'";Text$;"' MemSize:'";sSize;"' Ptr:'";vobject_text(vot);"' Len:'";Size - 4;"'"
ENDIF
COPY MEMORY vobject_text(vot) + vot_string_pos, TextPtr, Size - 4
POKE BYTE vobject_text(vot) + Size, 0
POKE INTEGER vobject_text(vot), 1
INC vobject_text_count
ELSE
vot = returnval
Textcount = PEEK INTEGER(vobject_text(vot))
POKE INTEGER vobject_text(vot), Textcount + 1
ENDIF
returnval = vobject_text(vot)
ENDFUNCTION returnval
Actually really important is only this bit:
vot = xvobject_text_id_generate()
Size = FAST LEN(Text$) + 4
vobject_text(vot) = ALLOC ZEROED(Size)
sSize = MEMORY SIZE(vobject_text(vot))
IF sSize <> Size
PRINT "String:'";Text$;"' MemSize:'";sSize;"' Ptr:'";vobject_text(vot);"' Len:'";Size - 4;"'"
ENDIF
Well maybe there is even something fuzzy going on because I'm using the ptr to a normal dbp string:
TextPtr = GET STRING PTR(Text$)
But then again it doesn't have anything to do with the allocation and memory size.
I can also change the code to this:
vot = xvobject_text_id_generate()
Size = FAST LEN(Text$) + 4
vobject_text(vot) = ALLOC ZEROED(Size)
sSize = MEMORY SIZE(vobject_text(vot))
COPY MEMORY vobject_text(vot) + 4, TextPtr, Size - 4
IF sSize <> Size
PRINT "String:'"; PEEK STRING(vobject_text(vot) + 4);"' MemSize:'";sSize;"' Ptr:'";vobject_text(vot);"' Len:'";Size - 4;"'"
ENDIF
PEEK STRING(vobject_text(vot) + 4) is printed out just fine.
It let's me write to the memory and read from it without a problem!
Just Memory Size is a jerk and gives me a bonkers value XD.
Btw.:
I asked this in several threads now ... and never got an answer XD:
How can I display my codesnippets in coloured text?
I saw that in other threads ... but I can't figure out how it works XD.
EDIT:
Maybe I should give some more information. If you are interested you can take a look
here and as I said:
Here is the source code.
In my system I'm handling text like this:
I want the text to exist only once in memory.
So every time I create a new text value for any of my objects I check if the text already exists within the text objects. If so I'm just pointing to the same text object.
Like that:
http://i.imgur.com/yN30FA1.jpg
Every text values in my system is handled like that, it's always a pointer to the text object.
The first 4 bytes of the text object is an integer count how often this text is pointed to.
Compare strings:
Now to speed things up I never compare strings themselves.
I compare the sizes of the text objects before I actually compare the memory of the strings.
I guess you know what happens. 
If I compare -9 to 7 or whatever bonkers sizes memory size is giving me ... this can't be working.
Before you think it: XD
I'll probably go berserk in the near future and replace many of the integer values with word and dword values.
I haven't really thought of that early enough.
Performance:
This turned out to be pretty fast with reasonable amounts of objects.
Current Speed:
- Create 10.000 VObjects, one string attribute each -> 40 ms.
- Filter them by a string value -> 10 ms.
I never thought I would get this to be as fast as it is now XD ... and there is still room for improvement

.
However, this memory size problem kind of messes up my string comparisons XD.
-> I uploaded the latest version of the source code.