Exemplo n.º 1
0
/*
    memory_tracker_check_integrity(char* file, unsigned int file)
      file - the file name where the check was placed
      line - the line in file where the check was placed
    If a padding_size was supplied to vpx_memory_tracker_init()
    this function will check ea. addr in the list verifying that
    addr-padding_size and addr+padding_size is filled with pad_value
*/
static void memory_tracker_check_integrity(char *file, unsigned int line)
{
    if (memtrack.padding_size)
    {
        int i,
            index = 0;
        unsigned char *p_show_me,
                 * p_show_me2;
        unsigned int tempme = memtrack.pad_value,
                     dead1,
                     dead2;
        unsigned char *x_bounds;
        struct mem_block *p = memtrack.head->next;

        while (p)
        {
            //x_bounds = (unsigned char*)p->addr;
            //back up VPX_BYTE_ALIGNMENT
            //x_bounds -= memtrack.padding_size;

            if (p->padded)   // can the bounds be checked?
            {
                /*yes, move to the address that was actually allocated
                by the vpx_* calls*/
                x_bounds = (unsigned char *)(((size_t *)p->addr)[-1]);

                for (i = 0; i < memtrack.padding_size; i += sizeof(unsigned int))
                {
                    p_show_me = (x_bounds + i);
                    p_show_me2 = (unsigned char *)(p->addr + p->size + i);

                    MEM_TRACK_MEMCPY(&dead1, p_show_me, sizeof(unsigned int));
                    MEM_TRACK_MEMCPY(&dead2, p_show_me2, sizeof(unsigned int));

                    if ((dead1 != tempme) || (dead2 != tempme))
                    {
                        memtrack_log("\n[vpx_mem integrity check failed]:\n"
                                     "    index[%d] {%s:%d} addr=0x%x, size=%d,"
                                     " file: %s, line: %d c0:0x%x c1:0x%x\n",
                                     index, file, line, p->addr, p->size, p->file,
                                     p->line, dead1, dead2);
                    }
                }
            }

            ++index;
            p = p->next;
        }
    }
}
Exemplo n.º 2
0
static void memory_tracker_check_integrity(char *file, unsigned int line) {
  if (memtrack.padding_size) {
    int i,
        index = 0;
    unsigned char *p_show_me,
             * p_show_me2;
    unsigned int tempme = memtrack.pad_value,
                 dead1,
                 dead2;
    unsigned char *x_bounds;
    struct mem_block *p = memtrack.head->next;

    while (p) {
      
      
      

      if (p->padded) { 
        x_bounds = (unsigned char *)(((size_t *)p->addr)[-1]);

        for (i = 0; i < memtrack.padding_size; i += sizeof(unsigned int)) {
          p_show_me = (x_bounds + i);
          p_show_me2 = (unsigned char *)(p->addr + p->size + i);

          MEM_TRACK_MEMCPY(&dead1, p_show_me, sizeof(unsigned int));
          MEM_TRACK_MEMCPY(&dead2, p_show_me2, sizeof(unsigned int));

          if ((dead1 != tempme) || (dead2 != tempme)) {
            memtrack_log("\n[vpx_mem integrity check failed]:\n"
                         "    index[%d,%d] {%s:%d} addr=0x%x, size=%d,"
                         " file: %s, line: %d c0:0x%x c1:0x%x\n",
                         index, i, file, line, p->addr, p->size, p->file,
                         p->line, dead1, dead2);
          }
        }
      }

      ++index;
      p = p->next;
    }
  }
}