Example #1
0
static int hdf_read_2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
{
    long outlen = 0;
    int coffset;

    if (offset == 0)
        hfd->cache_valid = 0;
    coffset = isincache (hfd, offset, len);
    if (coffset >= 0) {
        memcpy (buffer, hfd->cache + coffset, len);
        return len;
    }
    hfd->cache_offset = offset;
    if (offset + CACHE_SIZE > hfd->offset + (hfd->physsize - hfd->virtual_size))
        hfd->cache_offset = hfd->offset + (hfd->physsize - hfd->virtual_size) - CACHE_SIZE;
    hdf_seek (hfd, hfd->cache_offset);
    poscheck (hfd, CACHE_SIZE);
    if (hfd->handle_valid == HDF_HANDLE_LINUX)
        outlen = fread (hfd->cache, 1, CACHE_SIZE, hfd->handle->h);
    else if (hfd->handle_valid == HDF_HANDLE_ZFILE)
        outlen = zfile_fread (hfd->cache, 1, CACHE_SIZE, hfd->handle->zf);
    hfd->cache_valid = 0;
    if (outlen != CACHE_SIZE)
        return 0;
    hfd->cache_valid = 1;
    coffset = isincache (hfd, offset, len);
    if (coffset >= 0) {
        memcpy (buffer, hfd->cache + coffset, len);
        return len;
    }
    write_log ("hdf_read: cache bug! offset=0x%llx len=%d\n", offset, len);
    hfd->cache_valid = 0;
    return 0;
}
Example #2
0
 /**
  * TODO
  */
 ~dynlinkedlist() {
     Node * start_free = min_cache[0].next;
     min_cache[0].next=NULL;
     while(start_free){
         Node *tmp = start_free;
         start_free = start_free->next;
         tmp->next = NULL;
         tmp->next_data = NULL;
         if(!isincache(tmp)){
             free(tmp);
         }
     }
     free(cache_mem);
 }