MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / new_diskcache

Function new_diskcache

src/hdcache.c:305–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303}
304
305disk_t *new_diskcache(disk_t *disk_car, const unsigned int testdisk_mode)
306{
307 unsigned int i;
308 struct cache_struct*data=(struct cache_struct*)MALLOC(sizeof(*data));
309 disk_t *new_disk_car=(disk_t *)MALLOC(sizeof(*new_disk_car));
310 memcpy(new_disk_car,disk_car,sizeof(*new_disk_car));
311 data->disk_car=disk_car;
312#ifdef DEBUG_CACHE
313 data->nbr_fnct_sect=0;
314 data->nbr_pread_sect=0;
315 data->nbr_fnct_call=0;
316 data->nbr_pread_call=0;
317#endif
318 data->cache_buffer_nbr=0;
319 data->last_io_error_nbr=0;
320 if(testdisk_mode&TESTDISK_O_READAHEAD_8K)
321 data->cache_size_min=16*512;
322 else if(testdisk_mode&TESTDISK_O_READAHEAD_32K)
323 data->cache_size_min=64*512;
324 else
325 data->cache_size_min=0;
326 dup_geometry(&new_disk_car->geom,&disk_car->geom);
327 new_disk_car->disk_size=disk_car->disk_size;
328 new_disk_car->disk_real_size=disk_car->disk_real_size;
329 new_disk_car->write_used=0;
330 new_disk_car->data=data;
331 new_disk_car->pread=&cache_pread;
332 new_disk_car->pwrite=&cache_pwrite;
333 new_disk_car->sync=&cache_sync;
334 new_disk_car->clean=&cache_clean;
335 new_disk_car->description=&cache_description;
336 new_disk_car->description_short=&cache_description_short;
337 new_disk_car->rbuffer=NULL;
338 new_disk_car->wbuffer=NULL;
339 new_disk_car->rbuffer_size=0;
340 new_disk_car->wbuffer_size=0;
341 for(i=0;i<CACHE_BUFFER_NBR;i++)
342 {
343 data->cache[i].buffer=NULL;
344 data->cache[i].buffer_size=0;
345 }
346 return new_disk_car;
347}
348#endif

Callers 4

mainFunction · 0.85
display_disk_listFunction · 0.85
mainFunction · 0.85
QPhotorecMethod · 0.85

Calls 2

MALLOCFunction · 0.85
dup_geometryFunction · 0.85

Tested by 2

display_disk_listFunction · 0.68
mainFunction · 0.68