NeoMutt  2024-04-16-36-g75b6fb
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
msgwin_wdata.c
Go to the documentation of this file.
1
29#include "config.h"
30#include <stddef.h>
31#include "mutt/lib.h"
32#include "msgwin_wdata.h"
33
37void msgwin_wdata_free(struct MuttWindow *win, void **ptr)
38{
39 if (!ptr || !*ptr)
40 return;
41
42 struct MsgWinWindowData *wdata = *ptr;
43
44 for (int i = 0; i < MSGWIN_MAX_ROWS; i++)
45 {
46 ARRAY_FREE(&wdata->rows[i]);
47 }
48
49 // We don't own MwChar->ac_color, so there's nothing but the ARRAY to free
50 ARRAY_FREE(&wdata->chars);
51 buf_free(&wdata->text);
52
53 FREE(ptr);
54}
55
61{
62 struct MsgWinWindowData *wdata = mutt_mem_calloc(1, sizeof(struct MsgWinWindowData));
63
64 wdata->text = buf_new(NULL);
65
66 return wdata;
67}
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:204
void buf_free(struct Buffer **ptr)
Deallocates a buffer.
Definition: buffer.c:318
struct Buffer * buf_new(const char *str)
Allocate a new Buffer.
Definition: buffer.c:303
void msgwin_wdata_free(struct MuttWindow *win, void **ptr)
Free the private data - Implements MuttWindow::wdata_free() -.
Definition: msgwin_wdata.c:37
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
#define FREE(x)
Definition: memory.h:45
struct MsgWinWindowData * msgwin_wdata_new(void)
Create new private data for the Message Window.
Definition: msgwin_wdata.c:60
Message Window private data.
#define MSGWIN_MAX_ROWS
Definition: msgwin_wdata.h:30
Convenience wrapper for the library headers.
Message Window private Window data.
Definition: msgwin_wdata.h:66
struct Buffer * text
Cached display string.
Definition: msgwin_wdata.h:67
struct MwCharArray chars
Text: Breakdown of bytes and widths.
Definition: msgwin_wdata.h:68
struct MwChunkArray rows[MSGWIN_MAX_ROWS]
String byte counts for each row.
Definition: msgwin_wdata.h:69