refactor: stack allocation for referenced_message
@@ -27,18 +27,20 @@ void on_message_create(
return;
message::create::params params = {
- .content = (char*)msg->content //this won't be modified
+ .content = msg->content
};
- if(msg->referenced_message)
- {
- params.message_reference = message::reference::dati_alloc();
- params.message_reference->message_id = msg->referenced_message->id;
- params.message_reference->channel_id = msg->referenced_message->channel_id;
- params.message_reference->guild_id = msg->referenced_message->guild_id;
+
+ message::reference::dati msg_ref;
+ message::reference::dati_init(&msg_ref);
+ if(msg->referenced_message) {
+ msg_ref.message_id = msg->referenced_message->id;
+ msg_ref.channel_id = msg->channel_id;
+ msg_ref.guild_id = msg->guild_id;
+
+ params.message_reference = &msg_ref;
}
message::create::run(client, msg->channel_id, &params, NULL);
- message::reference::dati_free(params.message_reference);
}
void on_message_update(
