memory cleanup reorganized
This commit is contained in:
parent
0d8f599ac9
commit
d30fa55af7
6 changed files with 26 additions and 0 deletions
|
@ -74,4 +74,11 @@ int config_path(char* config_root, char* extension, char* result, int max_len);
|
||||||
*/
|
*/
|
||||||
int repo_config_init(struct RepoConfig* config, unsigned int num_bits_for_keypair, char* repo_path);
|
int repo_config_init(struct RepoConfig* config, unsigned int num_bits_for_keypair, char* repo_path);
|
||||||
|
|
||||||
|
/***
|
||||||
|
* free all resources that were allocated to store config information
|
||||||
|
* @param config the config
|
||||||
|
* @returns true(1)
|
||||||
|
*/
|
||||||
|
int repo_config_free(struct RepoConfig* config);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -32,5 +32,6 @@ int repo_config_addresses_init(struct Addresses* addresses, char* api, char* gat
|
||||||
int repo_config_addresses_free(struct Addresses* addresses) {
|
int repo_config_addresses_free(struct Addresses* addresses) {
|
||||||
free(addresses->api);
|
free(addresses->api);
|
||||||
free(addresses->gateway);
|
free(addresses->gateway);
|
||||||
|
repo_config_swarm_address_free(&(addresses->swarm));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "mbedtls/base64.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* encode using base64
|
* encode using base64
|
||||||
|
|
|
@ -134,3 +134,14 @@ int repo_config_init(struct RepoConfig* config, unsigned int num_bits_for_keypai
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int repo_config_free(struct RepoConfig* config) {
|
||||||
|
repo_config_bootstrap_peers_free(&(config->peer_addresses));
|
||||||
|
repo_config_datastore_free(&(config->datastore));
|
||||||
|
repo_config_addresses_free(&(config->addresses));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int repo_config_martial_to_json(struct RepoConfig* config) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,9 @@ int fs_repo_open(char* repo_path, struct FSRepo* repo) {
|
||||||
//TODO: lock
|
//TODO: lock
|
||||||
// get the path set in the repo struct
|
// get the path set in the repo struct
|
||||||
int retVal = repo_new_fs_repo(repo_path, repo);
|
int retVal = repo_new_fs_repo(repo_path, repo);
|
||||||
|
if (retVal == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
// check if initialized
|
// check if initialized
|
||||||
if (!repo_check_initialized(repo->path))
|
if (!repo_check_initialized(repo->path))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -16,6 +16,7 @@ int test_repo_config_init() {
|
||||||
int retVal = repo_config_init(&repoConfig, 2048, "/Users/JohnJones/.ipfs");
|
int retVal = repo_config_init(&repoConfig, 2048, "/Users/JohnJones/.ipfs");
|
||||||
if (retVal == 0)
|
if (retVal == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// now tear it apart to check for anything broken
|
// now tear it apart to check for anything broken
|
||||||
|
|
||||||
// addresses
|
// addresses
|
||||||
|
@ -31,6 +32,8 @@ int test_repo_config_init() {
|
||||||
if (retVal != 0)
|
if (retVal != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
repo_config_free(&repoConfig);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue