Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Add wallet_init() API #43

Merged
merged 4 commits into from May 12, 2015
Merged

Add wallet_init() API #43

merged 4 commits into from May 12, 2015

Conversation

ghost
Copy link

@ghost ghost commented May 7, 2015

No description provided.

The wallet_init() API can be used to initialize a struct wallet object
on the callers stack.

Rework wallet_new() to use wallet_init().
@jgarzik
Copy link
Owner

jgarzik commented May 7, 2015

Good progress - though there needs to be a counterpart that frees the internal members as well.

Take a look at include/ccoin/core.h for the style to follow. _init initializes internal members. _free frees internal members. This is modelled on OpenSSL.

I realize that some parts of picocoin do not follow this style - and that is my error.

@ghost
Copy link
Author

ghost commented May 7, 2015

Woops, yeah. Definitely need a free. I need to slow down a bit, I think :).

So, should we really even have a wallet_new() API? Or, should we just require all users to handle the allocation of the wallet itself. I had thought we needed both, but having only wallet_init() seems like it would be simpler (and mimics what you've done in core.h).

@jgarzik
Copy link
Owner

jgarzik commented May 7, 2015

@JoshCartwright The default answer to that question is "no"

However, the practical answer is situational. If many places in the code are dynamically allocating & free'ing, rather than embedding the structure, a helper wrapper is just fine, on top of the core _init() and _free() functions that init/free internal members.

@ghost
Copy link
Author

ghost commented May 7, 2015

@jgarzik I just decided to drop wallet_new() for now, it can always be resurrected. Thanks for the careful guidance!

@jgarzik
Copy link
Owner

jgarzik commented May 8, 2015

Modulo bug fixes -ACK

Josh Cartwright added 3 commits May 7, 2015 20:30
To be consistent with the other libccoin APIs, make the responsibility
of managing the storage of the struct wallet the responsibility of the
caller.

Notably, this makes wallet_free() _not_ free the wallet object itself,
but only the internal members.
The following memset() will take care of setting the keys member to
NULL.
@ghost
Copy link
Author

ghost commented May 11, 2015

@jgarzik bug fixes addressed & rebased.

@jgarzik
Copy link
Owner

jgarzik commented May 12, 2015

merged

jgarzik pushed a commit that referenced this pull request May 12, 2015
@jgarzik jgarzik merged commit 1b38ece into jgarzik:master May 12, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant