C++ API changes+fixes:

- context is now a pointer to make sure there's only one all the time
- fixed a couple of double free's
- some minor bug fixes
This commit is contained in:
git@daemon.de
2014-08-01 14:46:38 +02:00
parent 1e4e65b811
commit e6a5c51d8a
13 changed files with 168 additions and 114 deletions

View File

@@ -37,9 +37,9 @@ namespace pcp {
class exception : public std::runtime_error {
private:
PCPCTX *ptx;
std::string getfatals(PcpContext &P) {
std::string getfatals(PcpContext *P) {
std::string msg;
PCPCTX *ptx = P.ptx;
PCPCTX *ptx = P->ptx;
if(ptx->pcp_errset == 1) {
msg = ptx->pcp_err;
}
@@ -51,8 +51,8 @@ namespace pcp {
return msg;
}
public:
exception(PcpContext &P, const std::string & msg) : runtime_error(msg) { ptx = P.ptx; }
exception(PcpContext &P) : runtime_error(getfatals(P)) { }
exception(PcpContext *P, const std::string & msg) : runtime_error(msg) { ptx = P->ptx; }
exception(PcpContext *P) : runtime_error(getfatals(P)) { }
};