Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/majn/tgl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvvaltman <vvaltman@neon>2015-06-18 15:54:42 +0300
committervvaltman <vvaltman@neon>2015-06-18 15:54:42 +0300
commit638b26d60455b82c55b96dfe2043108c52e50952 (patch)
tree482e88c850289f8713ff8dd6bc3a6edfeb0fcaed /structures.c
parentd9769636bcd5d2b209c956e15eca4a81f9e677e9 (diff)
small fixes
Diffstat (limited to 'structures.c')
-rw-r--r--structures.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/structures.c b/structures.c
index b394264..7393f86 100644
--- a/structures.c
+++ b/structures.c
@@ -1618,11 +1618,12 @@ struct tgl_bot_info *tglf_fetch_alloc_bot_info (struct tgl_state *TLS, struct tl
return B;
}
-struct tgl_message_reply_markup *tglf_fetch_alloc_reply_markup (struct tgl_state *TLS, struct tl_ds_reply_markup *DS_RM) {
+struct tgl_message_reply_markup *tglf_fetch_alloc_reply_markup (struct tgl_state *TLS, struct tgl_message *M, struct tl_ds_reply_markup *DS_RM) {
if (!DS_RM) { return NULL; }
-
+
struct tgl_message_reply_markup *R = talloc0 (sizeof (*R));
R->flags = DS_LVAL (DS_RM->flags);
+ R->refcnt = 1;
R->rows = DS_LVAL (DS_RM->rows->cnt);
@@ -1840,8 +1841,21 @@ void tgls_clear_message (struct tgl_state *TLS, struct tgl_message *M) {
}
}
+void tgls_free_reply_markup (struct tgl_state *TLS, struct tgl_message_reply_markup *R) {
+ if (!--R->refcnt) {
+ tfree (R->buttons, R->row_start[R->rows] * sizeof (void *));
+ tfree (R->row_start, 4 * (R->rows + 1));
+ tfree (R, sizeof (*R));
+ } else {
+ assert (R->refcnt > 0);
+ }
+}
+
void tgls_free_message (struct tgl_state *TLS, struct tgl_message *M) {
tgls_clear_message (TLS, M);
+ if (M->reply_markup) {
+ tgls_free_reply_markup (TLS, M->reply_markup);
+ }
tfree (M, sizeof (*M));
}