cpp types further migration

master
bqv 2 years ago
parent 0cec6dad8d
commit 3d49f1a685
No known key found for this signature in database
GPG Key ID: 9E2FF3BDEBDFC910

@ -178,7 +178,7 @@ xmpp_stanza_t *weechat::account::get_devicelist()
device.name = fmt::format("%u", device.id);
device.label = "weechat";
auto children = (xmpp_stanza_t **)malloc(sizeof(xmpp_stanza_t *) * 128);
auto children = new xmpp_stanza_t*[128];
children[i++] = stanza__iq_pubsub_publish_item_list_device(
context, NULL, with_noop(device.name.data()), NULL);
@ -203,7 +203,7 @@ xmpp_stanza_t *weechat::account::get_devicelist()
xmpp_stanza_t * parent = stanza__iq(context, NULL,
children, NULL, strdup("announce1"),
NULL, NULL, strdup("set"));
free(children);
delete[] children;
return parent;
}

@ -395,7 +395,7 @@ int weechat::channel::add_typing(weechat::user *user)
new_typing = weechat::channel::typing_search(user->id);
if (!new_typing)
{
new_typing = (weechat::channel::typing*)malloc(sizeof(*new_typing));
new_typing = new weechat::channel::typing();
new_typing->id = strdup(user->id);
new_typing->name = strdup(user->profile.display_name);
@ -454,7 +454,7 @@ int weechat::channel::add_self_typing(weechat::user *user)
new_typing = self_typing_search(user);
if (!new_typing)
{
new_typing = (weechat::channel::typing*)malloc(sizeof(*new_typing));
new_typing = new weechat::channel::typing();
new_typing->user = user;
new_typing->name = user ? strdup(user->profile.display_name) : NULL;
@ -520,7 +520,7 @@ weechat::channel::member *weechat::channel::add_member(const char *id, const cha
if (!(member = member_search(id)))
{
member = (weechat::channel::member*)malloc(sizeof(weechat::channel::member));
member = new weechat::channel::member();
member->id = strdup(id);
member->role = NULL;

@ -141,11 +141,11 @@ void completion__init()
size_t length = snprintf(NULL, 0, "%s|%s",
default_template,
"%(xmpp_account)") + 1;
char *new_template = (char*)malloc(length);
char *new_template = new char[length];
snprintf(new_template, length, "%s|%s",
default_template,
"%(xmpp_account)");
weechat_config_option_set(option, new_template, 1);
free(new_template);
delete[] new_template;
}
}

@ -1373,7 +1373,7 @@ bool weechat::connection::conn_handler(event status, int error, xmpp_stream_erro
char* rand_string(int length)
{
char *string = (char*)malloc(length);
char *string = new char[length];
for(int i = 0; i < length; ++i){
string[i] = '0' + rand()%72; // starting on '0', ending on '}'
if (!((string[i] >= '0' && string[i] <= '9') ||
@ -1398,7 +1398,7 @@ int weechat::connection::connect(std::string jid, std::string password, weechat:
char *const rand = rand_string(8);
char ident[64] = {0};
snprintf(ident, sizeof(ident), "weechat.%s", rand);
free(rand);
delete[] rand;
account.resource(ident);
resource = account.resource().data();

@ -96,7 +96,7 @@ char *message__translate_code(weechat::account *account,
free(identifier);
resultlen = snprintf(NULL, 0, "%s%s%s%s", weechat_color("chat_nick"), prefix, symbol, weechat_color("reset")) + 1;
result = (char*)malloc(resultlen);
result = new char[resultlen];
snprintf(result, resultlen, "%s%s%s%s", weechat_color("chat_nick"), prefix, symbol, weechat_color("reset"));
free(symbol);
@ -170,7 +170,7 @@ char *message__decode(weechat::account *account,
return strdup(text);
}
decoded_text = (char*)malloc(MESSAGE_MAX_LENGTH);
decoded_text = new char[MESSAGE_MAX_LENGTH];
if (!decoded_text)
{
regfree(&reg);
@ -190,7 +190,7 @@ char *message__decode(weechat::account *account,
if (!copy)
{
regfree(&reg);
free(decoded_text);
delete[] decoded_text;
weechat_printf(
account->buffer,
_("%s%s: error allocating space for message"),
@ -204,7 +204,7 @@ char *message__decode(weechat::account *account,
{
free(copy);
regfree(&reg);
free(decoded_text);
delete[] decoded_text;
weechat_printf(
account->buffer,
_("%s%s: error allocating space for message"),
@ -219,7 +219,7 @@ char *message__decode(weechat::account *account,
free(match);
free(copy);
regfree(&reg);
free(decoded_text);
delete[] decoded_text;
weechat_printf(
account->buffer,
_("%s%s: error allocating space for message"),
@ -237,7 +237,7 @@ char *message__decode(weechat::account *account,
strncat(decoded_text, replacement,
MESSAGE_MAX_LENGTH - strlen(decoded_text) - 1);
free(replacement);
delete[] replacement;
}
strncat(decoded_text, cursor,
MESSAGE_MAX_LENGTH - strlen(decoded_text) - 1);

@ -171,22 +171,22 @@ encrypt_finish:
char *weechat::xmpp::pgp::decrypt(struct t_gui_buffer *buffer, const char *ciphertext)
{
std::string decrypted;
uint8_t * buf = NULL;
size_t buf_len = 0;
char * result = NULL;
std::unique_ptr<char> buf;
size_t buf_len = 0;
char * result = NULL;
int ret;
buf_len = strlen(PGP_MESSAGE_HEADER) + strlen(ciphertext) + strlen(PGP_MESSAGE_FOOTER) + 1;
buf = (uint8_t*)malloc(sizeof(char) * buf_len);
buf_len = snprintf((char *)buf, buf_len, PGP_MESSAGE_HEADER "%s" PGP_MESSAGE_FOOTER, ciphertext);
buf = std::unique_ptr<char>(new char[buf_len]);
buf_len = snprintf(&*buf, buf_len, PGP_MESSAGE_HEADER "%s" PGP_MESSAGE_FOOTER, ciphertext);
std::string keyids;
gpgme_error_t err;
gpgme_data_t in, out;
/* Initialize input buffer. */
err = gpgme_data_new_from_mem(&in, (char *)buf, buf_len, false);
err = gpgme_data_new_from_mem(&in, &*buf, buf_len, false);
if (err) {
goto decrypt_finish;
}
@ -236,13 +236,13 @@ decrypt_finish:
char *weechat::xmpp::pgp::verify(struct t_gui_buffer *buffer, const char *certificate)
{
uint8_t * buf = NULL;
size_t buf_len = 0;
char * result = NULL;
std::unique_ptr<char> buf;
size_t buf_len = 0;
char * result = NULL;
buf_len = strlen(PGP_SIGNATURE_HEADER) + strlen(certificate) + strlen(PGP_SIGNATURE_FOOTER) + 1;
buf = (uint8_t*)malloc(sizeof(char) * buf_len);
buf_len = snprintf((char *)buf, buf_len, PGP_SIGNATURE_HEADER "%s" PGP_SIGNATURE_FOOTER, certificate);
buf = std::unique_ptr<char>(new char[buf_len]);
buf_len = snprintf(&*buf, buf_len, PGP_SIGNATURE_HEADER "%s" PGP_SIGNATURE_FOOTER, certificate);
gpgme_verify_result_t vrf_result;
gpgme_error_t err;
@ -250,7 +250,7 @@ char *weechat::xmpp::pgp::verify(struct t_gui_buffer *buffer, const char *certif
gpgme_key_t key;
/* Initialize input buffer. */
err = gpgme_data_new_from_mem(&in, (char *)buf, buf_len, false);
err = gpgme_data_new_from_mem(&in, &*buf, buf_len, false);
if (err) {
goto verify_finish;
}

Loading…
Cancel
Save