Commit fc109e21 authored by Sylvain Berfini's avatar Sylvain Berfini 🐮
Browse files

Get rid of BelCardParser instance

parent a445dabd
...@@ -56,8 +56,8 @@ void linphone_vcard_free(LinphoneVcard *vCard) { ...@@ -56,8 +56,8 @@ void linphone_vcard_free(LinphoneVcard *vCard) {
bctbx_list_t* linphone_vcard_list_from_vcard4_file(const char *filename) { bctbx_list_t* linphone_vcard_list_from_vcard4_file(const char *filename) {
bctbx_list_t *result = NULL; bctbx_list_t *result = NULL;
if (filename) { if (filename) {
belcard::BelCardParser parser = belcard::BelCardParser::getInstance(); belcard::BelCardParser *parser = new belcard::BelCardParser();
shared_ptr<belcard::BelCardList> belCards = parser.parseFile(filename); shared_ptr<belcard::BelCardList> belCards = parser->parseFile(filename);
if (belCards) { if (belCards) {
for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) { for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) {
shared_ptr<belcard::BelCard> belCard = (*it); shared_ptr<belcard::BelCard> belCard = (*it);
...@@ -65,6 +65,7 @@ bctbx_list_t* linphone_vcard_list_from_vcard4_file(const char *filename) { ...@@ -65,6 +65,7 @@ bctbx_list_t* linphone_vcard_list_from_vcard4_file(const char *filename) {
result = bctbx_list_append(result, vCard); result = bctbx_list_append(result, vCard);
} }
} }
free(parser);
} }
return result; return result;
} }
...@@ -72,8 +73,8 @@ bctbx_list_t* linphone_vcard_list_from_vcard4_file(const char *filename) { ...@@ -72,8 +73,8 @@ bctbx_list_t* linphone_vcard_list_from_vcard4_file(const char *filename) {
bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(const char *buffer) { bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(const char *buffer) {
bctbx_list_t *result = NULL; bctbx_list_t *result = NULL;
if (buffer) { if (buffer) {
belcard::BelCardParser parser = belcard::BelCardParser::getInstance(); belcard::BelCardParser *parser = new belcard::BelCardParser();
shared_ptr<belcard::BelCardList> belCards = parser.parse(buffer); shared_ptr<belcard::BelCardList> belCards = parser->parse(buffer);
if (belCards) { if (belCards) {
for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) { for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) {
shared_ptr<belcard::BelCard> belCard = (*it); shared_ptr<belcard::BelCard> belCard = (*it);
...@@ -81,6 +82,7 @@ bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(const char *buffer) { ...@@ -81,6 +82,7 @@ bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(const char *buffer) {
result = bctbx_list_append(result, vCard); result = bctbx_list_append(result, vCard);
} }
} }
free(parser);
} }
return result; return result;
} }
...@@ -88,13 +90,14 @@ bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(const char *buffer) { ...@@ -88,13 +90,14 @@ bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(const char *buffer) {
LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(const char *buffer) { LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(const char *buffer) {
LinphoneVcard *vCard = NULL; LinphoneVcard *vCard = NULL;
if (buffer) { if (buffer) {
belcard::BelCardParser parser = belcard::BelCardParser::getInstance(); belcard::BelCardParser *parser = new belcard::BelCardParser();
shared_ptr<belcard::BelCard> belCard = parser.parseOne(buffer); shared_ptr<belcard::BelCard> belCard = parser->parseOne(buffer);
if (belCard) { if (belCard) {
vCard = linphone_vcard_new_from_belcard(belCard); vCard = linphone_vcard_new_from_belcard(belCard);
} else { } else {
ms_error("Couldn't parse buffer %s", buffer); ms_error("Couldn't parse buffer %s", buffer);
} }
free(parser);
} }
return vCard; return vCard;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment