-
Notifications
You must be signed in to change notification settings - Fork 83
Conversation
The wallet_init() API can be used to initialize a struct wallet object on the callers stack. Rework wallet_new() to use wallet_init().
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. |
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). |
@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. |
@jgarzik I just decided to drop wallet_new() for now, it can always be resurrected. Thanks for the careful guidance! |
Modulo bug fixes -ACK |
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.
@jgarzik bug fixes addressed & rebased. |
merged |
No description provided.