gnupic: Thread: some problem in source code--gpmemory.c


[<<] [<] Page 1 of 1 [>] [>>]
Subject: some problem in source code--gpmemory.c
From: feqin fan ####@####.####
Date: 11 Jul 2012 05:03:31 -0000
Message-Id: <CAOfAq_q8iKK+NC50991BVQX0Hao1xMgm70g60ffE22KxeOXz+g@mail.gmail.com>

Hi,It's me Again.  (# ̄� ̄#)

../gputils-0.14.2/gputils-0.14.2/libgputils/gpmemory.c

in the Line 132 the source code is :

  int b_memory_get(MemBlock *m, unsigned int address, unsigned char *byte)
  {

    do {
      assert(m->memory != NULL);

      if( ((address >> I_MEM_BITS) & 0xFFFF) == m->base ) {
        *byte = m->memory[address & I_MEM_MASK] & 0xFF;
        return (m->memory[address & I_MEM_MASK] & BYTE_USED_MASK) != 0;
      }

      m = m->next;
    } while(m);

    return 0;
  }

I can see that the MemBlock->base must be the high 16 bit of the second
parameter address(I called this ****conclusion A****).

BUT,function b_memory_put (in Line 163) have source line (Line 187 and 188)
>>   m = i_memory_new(i_memory, (MemBlock *) malloc(sizeof(MemBlock)),
address);
       m->memory[address & I_MEM_MASK] = value | BYTE_USED_MASK;

but we can not make sure it accord with conclusion A, the address return by
calloc and malloc is random..

so who can tell me why??
THX guys..

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

live long and prosper..
[<<] [<] Page 1 of 1 [>] [>>]


Powered by ezmlm-browse 0.20.