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

Function file_add_data

src/psearch.h:28–52  ·  view source on GitHub ↗

@ @ requires \valid(data); @*/

Source from the content-addressed store, hash-verified

26 @ requires \valid(data);
27 @*/
28static inline alloc_data_t *file_add_data(alloc_data_t *data, const uint64_t offset, const unsigned int content)
29{
30 if(!(data->start <= offset && offset <= data->end))
31 {
32 log_critical("file_add_data: bug\n");
33 return data;
34 }
35 if(data->start==offset)
36 {
37 data->data=content;
38 return data;
39 }
40 if(data->data==content)
41 return data;
42 {
43 alloc_data_t *datanext=(alloc_data_t*)MALLOC(sizeof(*datanext));
44 memcpy(datanext, data, sizeof(*datanext));
45 data->end=offset-1;
46 datanext->start=offset;
47 datanext->file_stat=NULL;
48 datanext->data=content;
49 td_list_add(&datanext->list, &data->list);
50 return datanext;
51 }
52}
53
54/*@
55 @ requires \valid(dst);

Callers

nothing calls this directly

Calls 2

MALLOCFunction · 0.85
td_list_addFunction · 0.85

Tested by

no test coverage detected