mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
[cdatapack] fix memory handling for cdatapack
Summary: `->index_table` is not heap-alloacted. however, `->fanout_table` is and should be released. Also added call to `close_datapack()` at the end of `cdatapack_dump.c`. Depends on D3627122 Test Plan: valgrind is much happier now. Reviewers: durham Reviewed By: durham Subscribers: mitrandir Differential Revision: https://phabricator.intern.facebook.com/D3631368 Signature: t1:3631368:1469741779:e0c4e5d59c7e73c8aa3507901df3005383f0d3f5
This commit is contained in:
parent
705c0731b6
commit
20126b3bd8
@ -276,7 +276,11 @@ error_cleanup:
|
||||
if (handle && handle->datafd != 0) {
|
||||
close(handle->datafd);
|
||||
}
|
||||
free(handle->index_table);
|
||||
|
||||
if (handle != NULL) {
|
||||
free(handle->fanout_table);
|
||||
}
|
||||
|
||||
free(handle);
|
||||
|
||||
handle = NULL;
|
||||
@ -293,7 +297,7 @@ void close_datapack(datapack_handle_t *handle) {
|
||||
munmap(handle->data_mmap, handle->data_file_sz);
|
||||
close(handle->indexfd);
|
||||
close(handle->datafd);
|
||||
free(handle->index_table);
|
||||
free(handle->fanout_table);
|
||||
free(handle);
|
||||
}
|
||||
|
||||
@ -410,3 +414,8 @@ delta_chain_t *getdeltachain(
|
||||
|
||||
return delta_chain;
|
||||
}
|
||||
|
||||
void freedeltachain(delta_chain_t *chain) {
|
||||
free(chain->delta_chain_links);
|
||||
free(chain);
|
||||
}
|
||||
|
@ -87,6 +87,8 @@ extern delta_chain_t *getdeltachain(
|
||||
const datapack_handle_t *handle,
|
||||
uint8_t node[NODE_SZ]);
|
||||
|
||||
extern void freedeltachain(delta_chain_t *chain);
|
||||
|
||||
// this should really be private, but we need it for the cdatapack_dump tool.
|
||||
extern const uint8_t *getdeltachainlink(
|
||||
const uint8_t *ptr, delta_chain_link_t *link);
|
||||
|
@ -66,4 +66,6 @@ int main(int argc, char *argv[]) {
|
||||
NODE_SZ * 2, node_buffer, NODE_SZ * 2, deltabase_buffer,
|
||||
link.delta_sz);
|
||||
}
|
||||
|
||||
close_datapack(handle);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user