summaryrefslogtreecommitdiffstats
path: root/pcilib/pci.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2015-10-09 03:11:34 +0200
committerSuren A. Chilingaryan <csa@suren.me>2015-10-09 03:11:34 +0200
commit3b8e32c9bbe0d909c34303da0ad36ef0ef5be852 (patch)
treeed22378979b2889a84615cf9f24de76359a95244 /pcilib/pci.c
parent21812f8d763fac8ee9bb3fdc593642b06f405a2b (diff)
downloadpcitool-3b8e32c9bbe0d909c34303da0ad36ef0ef5be852.tar.gz
pcitool-3b8e32c9bbe0d909c34303da0ad36ef0ef5be852.tar.bz2
pcitool-3b8e32c9bbe0d909c34303da0ad36ef0ef5be852.tar.xz
pcitool-3b8e32c9bbe0d909c34303da0ad36ef0ef5be852.zip
Introduce hashes
Diffstat (limited to 'pcilib/pci.c')
-rw-r--r--pcilib/pci.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/pcilib/pci.c b/pcilib/pci.c
index 0ba5f51..4a0e79c 100644
--- a/pcilib/pci.c
+++ b/pcilib/pci.c
@@ -365,7 +365,6 @@ char *pcilib_resolve_data_space(pcilib_t *ctx, uintptr_t addr, size_t *size) {
void pcilib_close(pcilib_t *ctx) {
- int i;
pcilib_bar_t bar;
if (ctx) {
@@ -386,15 +385,6 @@ void pcilib_close(pcilib_t *ctx) {
pcilib_free_register_banks(ctx);
- if (ctx->register_ctx) {
- pcilib_register_t reg;
- for (reg = 0; reg < ctx->num_reg; reg++) {
- if (ctx->register_ctx[reg].views)
- free(ctx->register_ctx[reg].views);
- }
- free(ctx->register_ctx);
- }
-
if (ctx->event_plugin)
pcilib_plugin_close(ctx->event_plugin);
@@ -422,15 +412,22 @@ void pcilib_close(pcilib_t *ctx) {
if (ctx->pci_cfg_space_fd >= 0)
close(ctx->pci_cfg_space_fd);
- if (ctx->units);
- free(ctx->units);
+
+ if (ctx->units) {
+ pcilib_clean_units(ctx);
+ free(ctx->units);
+ }
if (ctx->views) {
- for (i = 0; ctx->views[i]; i++)
- free(ctx->views[i]);
+ pcilib_clean_views(ctx);
free(ctx->views);
}
+ pcilib_clean_registers(ctx);
+
+ if (ctx->register_ctx)
+ free(ctx->register_ctx);
+
if (ctx->registers)
free(ctx->registers);