How to substract two pointers like in C, to get the distance between them in 
some array?

Concider this example 
    
    
    byte *filebase, *file_p, *file_end;
    byte dlightdata[MAX_MAP_LIGHTING];
    
    byte *GetFileSpace (int size)
    {
            byte        *buf;
            file_p = (byte *)(((long)file_p + 3)&~3);
            buf = file_p;
            file_p += size;
            
            //intcount += (size + 3) & ~3; // fail attempt, the size is file_p+3
            
            if (file_p > file_end)
                    Error ("GetFileSpace: overrun");
            
            printf("BUF:: %p\n", buf);
            return buf;
    }
    
    // . . . LightThread() . . .
    out = GetFileSpace (lightmapsize);
    f->lightofs = out - filebase; // int f->lightofs;
    // . . .
    
    void LightWorld (void)
    {
            file_p = dlightdata;
            filebase = file_p;
            file_end = filebase + MAX_MAP_LIGHTING;
            
            LightThread();
            
            lightdatasize = file_p - filebase;
    }
    
    
    
    Run

Reply via email to