mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-14 05:33:59 -04:00
Convert most dynamic allocations to use functions from xmalloc.h
This commit is contained in:
parent
ecb2695822
commit
7a77958ba2
21 changed files with 133 additions and 68 deletions
12
base64.c
12
base64.c
|
|
@ -5,6 +5,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#define LOG_MODULE "base64"
|
#define LOG_MODULE "base64"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
|
|
@ -47,10 +48,14 @@ base64_decode(const char *s)
|
||||||
{
|
{
|
||||||
const size_t len = strlen(s);
|
const size_t len = strlen(s);
|
||||||
|
|
||||||
if (len % 4 != 0)
|
if (len % 4 != 0) {
|
||||||
|
errno = EINVAL;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
char *ret = malloc(len / 4 * 3 + 1);
|
char *ret = malloc(len / 4 * 3 + 1);
|
||||||
|
if (unlikely(ret == NULL))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (size_t i = 0, o = 0; i < len; i += 4, o += 3) {
|
for (size_t i = 0, o = 0; i < len; i += 4, o += 3) {
|
||||||
unsigned char c0 = s[i + 0];
|
unsigned char c0 = s[i + 0];
|
||||||
|
|
@ -60,6 +65,7 @@ base64_decode(const char *s)
|
||||||
|
|
||||||
if (!is_valid(c0) || !is_valid(c1) || !is_valid(c2) || !is_valid(c3)) {
|
if (!is_valid(c0) || !is_valid(c1) || !is_valid(c2) || !is_valid(c3)) {
|
||||||
free(ret);
|
free(ret);
|
||||||
|
errno = EINVAL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,10 +93,12 @@ char *
|
||||||
base64_encode(const uint8_t *data, size_t size)
|
base64_encode(const uint8_t *data, size_t size)
|
||||||
{
|
{
|
||||||
assert(size % 3 == 0);
|
assert(size % 3 == 0);
|
||||||
if (size %3 != 0)
|
if (unlikely(size % 3 != 0))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
char *ret = malloc(size / 3 * 4 + 1);
|
char *ret = malloc(size / 3 * 4 + 1);
|
||||||
|
if (unlikely(ret == NULL))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (size_t i = 0, o = 0; i < size; i += 3, o += 4) {
|
for (size_t i = 0, o = 0; i < size; i += 3, o += 4) {
|
||||||
int x = data[i + 0];
|
int x = data[i + 0];
|
||||||
|
|
|
||||||
3
client.c
3
client.c
|
|
@ -16,6 +16,7 @@
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
static volatile sig_atomic_t aborted = 0;
|
static volatile sig_atomic_t aborted = 0;
|
||||||
|
|
||||||
|
|
@ -201,7 +202,7 @@ main(int argc, char *const *argv)
|
||||||
errno = 0;
|
errno = 0;
|
||||||
size_t buf_len = 1024;
|
size_t buf_len = 1024;
|
||||||
do {
|
do {
|
||||||
cwd = realloc(cwd, buf_len);
|
cwd = xrealloc(cwd, buf_len);
|
||||||
if (getcwd(cwd, buf_len) == NULL && errno != ERANGE) {
|
if (getcwd(cwd, buf_len) == NULL && errno != ERANGE) {
|
||||||
LOG_ERRNO("failed to get current working directory");
|
LOG_ERRNO("failed to get current working directory");
|
||||||
goto err;
|
goto err;
|
||||||
|
|
|
||||||
2
config.c
2
config.c
|
|
@ -752,7 +752,7 @@ parse_section_key_bindings(
|
||||||
}
|
}
|
||||||
|
|
||||||
pipe_len = pipe_cmd_end - value - 1;
|
pipe_len = pipe_cmd_end - value - 1;
|
||||||
pipe_cmd = strndup(&value[1], pipe_len);
|
pipe_cmd = xstrndup(&value[1], pipe_len);
|
||||||
|
|
||||||
if (!tokenize_cmdline(pipe_cmd, &pipe_argv)) {
|
if (!tokenize_cmdline(pipe_cmd, &pipe_argv)) {
|
||||||
LOG_AND_NOTIFY_ERR("%s:%d: syntax error in command line", path, lineno);
|
LOG_AND_NOTIFY_ERR("%s:%d: syntax error in command line", path, lineno);
|
||||||
|
|
|
||||||
3
csi.c
3
csi.c
|
|
@ -18,6 +18,7 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "vt.h"
|
#include "vt.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
#define UNHANDLED() LOG_DBG("unhandled: %s", csi_as_string(term, final, -1))
|
#define UNHANDLED() LOG_DBG("unhandled: %s", csi_as_string(term, final, -1))
|
||||||
#define UNHANDLED_SGR(idx) LOG_DBG("unhandled: %s", csi_as_string(term, 'm', idx))
|
#define UNHANDLED_SGR(idx) LOG_DBG("unhandled: %s", csi_as_string(term, 'm', idx))
|
||||||
|
|
@ -933,7 +934,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
|
||||||
unsigned what = vt_param_get(term, 1, 0);
|
unsigned what = vt_param_get(term, 1, 0);
|
||||||
if (what == 0 || what == 2) {
|
if (what == 0 || what == 2) {
|
||||||
tll_push_back(
|
tll_push_back(
|
||||||
term->window_title_stack, strdup(term->window_title));
|
term->window_title_stack, xstrdup(term->window_title));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
extract.c
10
extract.c
|
|
@ -20,6 +20,11 @@ struct extraction_context *
|
||||||
extract_begin(enum selection_kind kind)
|
extract_begin(enum selection_kind kind)
|
||||||
{
|
{
|
||||||
struct extraction_context *ctx = malloc(sizeof(*ctx));
|
struct extraction_context *ctx = malloc(sizeof(*ctx));
|
||||||
|
if (unlikely(ctx == NULL)) {
|
||||||
|
LOG_ERRNO("malloc() failed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
*ctx = (struct extraction_context){
|
*ctx = (struct extraction_context){
|
||||||
.selection_kind = kind,
|
.selection_kind = kind,
|
||||||
};
|
};
|
||||||
|
|
@ -80,6 +85,11 @@ extract_finish(struct extraction_context *ctx, char **text, size_t *len)
|
||||||
}
|
}
|
||||||
|
|
||||||
*text = malloc(_len + 1);
|
*text = malloc(_len + 1);
|
||||||
|
if (unlikely(text == NULL)) {
|
||||||
|
LOG_ERRNO("malloc() failed");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
wcstombs(*text, ctx->buf, _len + 1);
|
wcstombs(*text, ctx->buf, _len + 1);
|
||||||
|
|
||||||
if (len != NULL)
|
if (len != NULL)
|
||||||
|
|
|
||||||
10
fdm.c
10
fdm.c
|
|
@ -50,6 +50,11 @@ fdm_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct fdm *fdm = malloc(sizeof(*fdm));
|
struct fdm *fdm = malloc(sizeof(*fdm));
|
||||||
|
if (unlikely(fdm == NULL)) {
|
||||||
|
LOG_ERRNO("malloc() failed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
*fdm = (struct fdm){
|
*fdm = (struct fdm){
|
||||||
.epoll_fd = epoll_fd,
|
.epoll_fd = epoll_fd,
|
||||||
.is_polling = false,
|
.is_polling = false,
|
||||||
|
|
@ -114,6 +119,11 @@ fdm_add(struct fdm *fdm, int fd, int events, fdm_handler_t handler, void *data)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct handler *fd_data = malloc(sizeof(*fd_data));
|
struct handler *fd_data = malloc(sizeof(*fd_data));
|
||||||
|
if (unlikely(fd_data == NULL)) {
|
||||||
|
LOG_ERRNO("malloc() failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
*fd_data = (struct handler) {
|
*fd_data = (struct handler) {
|
||||||
.fd = fd,
|
.fd = fd,
|
||||||
.events = events,
|
.events = events,
|
||||||
|
|
|
||||||
9
grid.c
9
grid.c
|
|
@ -8,6 +8,7 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "sixel.h"
|
#include "sixel.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
grid_swap_row(struct grid *grid, int row_a, int row_b)
|
grid_swap_row(struct grid *grid, int row_a, int row_b)
|
||||||
|
|
@ -28,16 +29,16 @@ grid_swap_row(struct grid *grid, int row_a, int row_b)
|
||||||
struct row *
|
struct row *
|
||||||
grid_row_alloc(int cols, bool initialize)
|
grid_row_alloc(int cols, bool initialize)
|
||||||
{
|
{
|
||||||
struct row *row = malloc(sizeof(*row));
|
struct row *row = xmalloc(sizeof(*row));
|
||||||
row->dirty = false;
|
row->dirty = false;
|
||||||
row->linebreak = false;
|
row->linebreak = false;
|
||||||
|
|
||||||
if (initialize) {
|
if (initialize) {
|
||||||
row->cells = calloc(cols, sizeof(row->cells[0]));
|
row->cells = xcalloc(cols, sizeof(row->cells[0]));
|
||||||
for (size_t c = 0; c < cols; c++)
|
for (size_t c = 0; c < cols; c++)
|
||||||
row->cells[c].attrs.clean = 1;
|
row->cells[c].attrs.clean = 1;
|
||||||
} else
|
} else
|
||||||
row->cells = malloc(cols * sizeof(row->cells[0]));
|
row->cells = xmalloc(cols * sizeof(row->cells[0]));
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
@ -65,7 +66,7 @@ grid_reflow(struct grid *grid, int new_rows, int new_cols,
|
||||||
int new_col_idx = 0;
|
int new_col_idx = 0;
|
||||||
int new_row_idx = 0;
|
int new_row_idx = 0;
|
||||||
|
|
||||||
struct row **new_grid = calloc(new_rows, sizeof(new_grid[0]));
|
struct row **new_grid = xcalloc(new_rows, sizeof(new_grid[0]));
|
||||||
struct row *new_row = new_grid[new_row_idx];
|
struct row *new_row = new_grid[new_row_idx];
|
||||||
|
|
||||||
assert(new_row == NULL);
|
assert(new_row == NULL);
|
||||||
|
|
|
||||||
5
input.c
5
input.c
|
|
@ -36,6 +36,7 @@
|
||||||
#include "tokenize.h"
|
#include "tokenize.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "vt.h"
|
#include "vt.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
struct pipe_context {
|
struct pipe_context {
|
||||||
char *text;
|
char *text;
|
||||||
|
|
@ -227,7 +228,7 @@ execute_binding(struct seat *seat, struct terminal *term,
|
||||||
/* Close read end */
|
/* Close read end */
|
||||||
close(pipe_fd[0]);
|
close(pipe_fd[0]);
|
||||||
|
|
||||||
ctx = malloc(sizeof(*ctx));
|
ctx = xmalloc(sizeof(*ctx));
|
||||||
*ctx = (struct pipe_context){
|
*ctx = (struct pipe_context){
|
||||||
.text = text,
|
.text = text,
|
||||||
.left = len,
|
.left = len,
|
||||||
|
|
@ -268,7 +269,7 @@ input_parse_key_binding(struct xkb_keymap *keymap, const char *combos,
|
||||||
|
|
||||||
xkb_keysym_t sym = XKB_KEY_NoSymbol;
|
xkb_keysym_t sym = XKB_KEY_NoSymbol;
|
||||||
|
|
||||||
char *copy = strdup(combos);
|
char *copy = xstrdup(combos);
|
||||||
|
|
||||||
for (char *save1 = NULL, *combo = strtok_r(copy, " ", &save1);
|
for (char *save1 = NULL, *combo = strtok_r(copy, " ", &save1);
|
||||||
combo != NULL;
|
combo != NULL;
|
||||||
|
|
|
||||||
11
main.c
11
main.c
|
|
@ -28,6 +28,7 @@
|
||||||
#include "shm.h"
|
#include "shm.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
static volatile sig_atomic_t aborted = 0;
|
static volatile sig_atomic_t aborted = 0;
|
||||||
|
|
||||||
|
|
@ -341,15 +342,15 @@ main(int argc, char *const *argv)
|
||||||
|
|
||||||
if (conf_term != NULL) {
|
if (conf_term != NULL) {
|
||||||
free(conf.term);
|
free(conf.term);
|
||||||
conf.term = strdup(conf_term);
|
conf.term = xstrdup(conf_term);
|
||||||
}
|
}
|
||||||
if (conf_title != NULL) {
|
if (conf_title != NULL) {
|
||||||
free(conf.title);
|
free(conf.title);
|
||||||
conf.title = strdup(conf_title);
|
conf.title = xstrdup(conf_title);
|
||||||
}
|
}
|
||||||
if (conf_app_id != NULL) {
|
if (conf_app_id != NULL) {
|
||||||
free(conf.app_id);
|
free(conf.app_id);
|
||||||
conf.app_id = strdup(conf_app_id);
|
conf.app_id = xstrdup(conf_app_id);
|
||||||
}
|
}
|
||||||
if (login_shell)
|
if (login_shell)
|
||||||
conf.login_shell = true;
|
conf.login_shell = true;
|
||||||
|
|
@ -367,7 +368,7 @@ main(int argc, char *const *argv)
|
||||||
conf.height = conf_height;
|
conf.height = conf_height;
|
||||||
if (conf_server_socket_path != NULL) {
|
if (conf_server_socket_path != NULL) {
|
||||||
free(conf.server_socket_path);
|
free(conf.server_socket_path);
|
||||||
conf.server_socket_path = strdup(conf_server_socket_path);
|
conf.server_socket_path = xstrdup(conf_server_socket_path);
|
||||||
}
|
}
|
||||||
if (maximized)
|
if (maximized)
|
||||||
conf.startup_mode = STARTUP_MAXIMIZED;
|
conf.startup_mode = STARTUP_MAXIMIZED;
|
||||||
|
|
@ -389,7 +390,7 @@ main(int argc, char *const *argv)
|
||||||
errno = 0;
|
errno = 0;
|
||||||
size_t buf_len = 1024;
|
size_t buf_len = 1024;
|
||||||
do {
|
do {
|
||||||
cwd = realloc(cwd, buf_len);
|
cwd = xrealloc(cwd, buf_len);
|
||||||
if (getcwd(cwd, buf_len) == NULL && errno != ERANGE) {
|
if (getcwd(cwd, buf_len) == NULL && errno != ERANGE) {
|
||||||
LOG_ERRNO("failed to get current working directory");
|
LOG_ERRNO("failed to get current working directory");
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,10 @@ executable(
|
||||||
executable(
|
executable(
|
||||||
'footclient',
|
'footclient',
|
||||||
'client.c',
|
'client.c',
|
||||||
'log.c', 'log.h', version,
|
'log.c', 'log.h',
|
||||||
|
'macros.h',
|
||||||
|
'xmalloc.c', 'xmalloc.h',
|
||||||
|
version,
|
||||||
install: true)
|
install: true)
|
||||||
|
|
||||||
tic = find_program('tic', native: true)
|
tic = find_program('tic', native: true)
|
||||||
|
|
|
||||||
19
osc.c
19
osc.c
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
@ -14,6 +15,7 @@
|
||||||
#include "selection.h"
|
#include "selection.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "vt.h"
|
#include "vt.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
#define UNHANDLED() LOG_DBG("unhandled: OSC: %.*s", (int)term->vt.osc.idx, term->vt.osc.data)
|
#define UNHANDLED() LOG_DBG("unhandled: OSC: %.*s", (int)term->vt.osc.idx, term->vt.osc.data)
|
||||||
|
|
||||||
|
|
@ -22,13 +24,16 @@ osc_to_clipboard(struct terminal *term, const char *target,
|
||||||
const char *base64_data)
|
const char *base64_data)
|
||||||
{
|
{
|
||||||
char *decoded = base64_decode(base64_data);
|
char *decoded = base64_decode(base64_data);
|
||||||
LOG_DBG("decoded: %s", decoded);
|
|
||||||
|
|
||||||
if (decoded == NULL) {
|
if (decoded == NULL) {
|
||||||
LOG_WARN("OSC: invalid clipboard data: %s", base64_data);
|
if (errno == EINVAL)
|
||||||
|
LOG_WARN("OSC: invalid clipboard data: %s", base64_data);
|
||||||
|
else
|
||||||
|
LOG_ERRNO("base64_decode() failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_DBG("decoded: %s", decoded);
|
||||||
|
|
||||||
bool to_clipboard = false;
|
bool to_clipboard = false;
|
||||||
bool to_primary = false;
|
bool to_primary = false;
|
||||||
|
|
||||||
|
|
@ -67,13 +72,13 @@ osc_to_clipboard(struct terminal *term, const char *target,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to_clipboard) {
|
if (to_clipboard) {
|
||||||
char *copy = strdup(decoded);
|
char *copy = xstrdup(decoded);
|
||||||
if (!text_to_clipboard(seat, term, copy, seat->kbd.serial))
|
if (!text_to_clipboard(seat, term, copy, seat->kbd.serial))
|
||||||
free(copy);
|
free(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to_primary) {
|
if (to_primary) {
|
||||||
char *copy = strdup(decoded);
|
char *copy = xstrdup(decoded);
|
||||||
if (!text_to_primary(seat, term, copy, seat->kbd.serial))
|
if (!text_to_primary(seat, term, copy, seat->kbd.serial))
|
||||||
free(copy);
|
free(copy);
|
||||||
}
|
}
|
||||||
|
|
@ -184,7 +189,7 @@ osc_from_clipboard(struct terminal *term, const char *source)
|
||||||
term_to_slave(term, &src, 1);
|
term_to_slave(term, &src, 1);
|
||||||
term_to_slave(term, ";", 1);
|
term_to_slave(term, ";", 1);
|
||||||
|
|
||||||
struct clip_context *ctx = malloc(sizeof(*ctx));
|
struct clip_context *ctx = xmalloc(sizeof(*ctx));
|
||||||
*ctx = (struct clip_context) {.seat = seat, .term = term};
|
*ctx = (struct clip_context) {.seat = seat, .term = term};
|
||||||
|
|
||||||
switch (src) {
|
switch (src) {
|
||||||
|
|
@ -374,7 +379,7 @@ osc_set_pwd(struct terminal *term, char *string)
|
||||||
|
|
||||||
/* Decode %xx encoded characters */
|
/* Decode %xx encoded characters */
|
||||||
const char *path = hostname_end;
|
const char *path = hostname_end;
|
||||||
char *pwd = malloc(strlen(path) + 1);
|
char *pwd = xmalloc(strlen(path) + 1);
|
||||||
char *p = pwd;
|
char *p = pwd;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
||||||
3
reaper.c
3
reaper.c
|
|
@ -10,6 +10,7 @@
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "tllist.h"
|
#include "tllist.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
struct reaper {
|
struct reaper {
|
||||||
struct fdm *fdm;
|
struct fdm *fdm;
|
||||||
|
|
@ -39,7 +40,7 @@ reaper_init(struct fdm *fdm)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct reaper *reaper = malloc(sizeof(*reaper));
|
struct reaper *reaper = xmalloc(sizeof(*reaper));
|
||||||
*reaper = (struct reaper){
|
*reaper = (struct reaper){
|
||||||
.fdm = fdm,
|
.fdm = fdm,
|
||||||
.fd = fd,
|
.fd = fd,
|
||||||
|
|
|
||||||
12
render.c
12
render.c
|
|
@ -22,6 +22,7 @@
|
||||||
#include "selection.h"
|
#include "selection.h"
|
||||||
#include "shm.h"
|
#include "shm.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
#define TIME_FRAME_RENDERING 0
|
#define TIME_FRAME_RENDERING 0
|
||||||
#define TIME_SCROLL_DAMAGE 0
|
#define TIME_SCROLL_DAMAGE 0
|
||||||
|
|
@ -43,7 +44,12 @@ static void fdm_hook_refresh_pending_terminals(struct fdm *fdm, void *data);
|
||||||
struct renderer *
|
struct renderer *
|
||||||
render_init(struct fdm *fdm, struct wayland *wayl)
|
render_init(struct fdm *fdm, struct wayland *wayl)
|
||||||
{
|
{
|
||||||
struct renderer *renderer = calloc(1, sizeof(*renderer));
|
struct renderer *renderer = malloc(sizeof(*renderer));
|
||||||
|
if (unlikely(renderer == NULL)) {
|
||||||
|
LOG_ERRNO("malloc() failed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
*renderer = (struct renderer) {
|
*renderer = (struct renderer) {
|
||||||
.fdm = fdm,
|
.fdm = fdm,
|
||||||
.wayl = wayl,
|
.wayl = wayl,
|
||||||
|
|
@ -1691,7 +1697,7 @@ grid_render(struct terminal *term)
|
||||||
if (feedback == NULL) {
|
if (feedback == NULL) {
|
||||||
LOG_WARN("failed to create presentation feedback");
|
LOG_WARN("failed to create presentation feedback");
|
||||||
} else {
|
} else {
|
||||||
struct presentation_context *ctx = malloc(sizeof(*ctx));
|
struct presentation_context *ctx = xmalloc(sizeof(*ctx));
|
||||||
*ctx = (struct presentation_context){
|
*ctx = (struct presentation_context){
|
||||||
.term = term,
|
.term = term,
|
||||||
.input.tv_sec = term->render.input_time.tv_sec,
|
.input.tv_sec = term->render.input_time.tv_sec,
|
||||||
|
|
@ -1840,7 +1846,7 @@ render_update_title(struct terminal *term)
|
||||||
char *copy = NULL;
|
char *copy = NULL;
|
||||||
|
|
||||||
if (strlen(title) > max_len) {
|
if (strlen(title) > max_len) {
|
||||||
copy = strndup(title, max_len);
|
copy = xstrndup(title, max_len);
|
||||||
title = copy;
|
title = copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
11
selection.c
11
selection.c
|
|
@ -20,6 +20,7 @@
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "vt.h"
|
#include "vt.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
bool
|
bool
|
||||||
selection_enabled(const struct terminal *term, struct seat *seat)
|
selection_enabled(const struct terminal *term, struct seat *seat)
|
||||||
|
|
@ -692,9 +693,9 @@ send(void *data, struct wl_data_source *wl_data_source, const char *mime_type,
|
||||||
size_t async_idx = 0;
|
size_t async_idx = 0;
|
||||||
switch (async_write(fd, selection, len, &async_idx)) {
|
switch (async_write(fd, selection, len, &async_idx)) {
|
||||||
case ASYNC_WRITE_REMAIN: {
|
case ASYNC_WRITE_REMAIN: {
|
||||||
struct clipboard_send *ctx = malloc(sizeof(*ctx));
|
struct clipboard_send *ctx = xmalloc(sizeof(*ctx));
|
||||||
*ctx = (struct clipboard_send) {
|
*ctx = (struct clipboard_send) {
|
||||||
.data = strdup(selection),
|
.data = xstrdup(selection),
|
||||||
.len = len,
|
.len = len,
|
||||||
.idx = async_idx,
|
.idx = async_idx,
|
||||||
};
|
};
|
||||||
|
|
@ -784,9 +785,9 @@ primary_send(void *data,
|
||||||
size_t async_idx = 0;
|
size_t async_idx = 0;
|
||||||
switch (async_write(fd, selection, len, &async_idx)) {
|
switch (async_write(fd, selection, len, &async_idx)) {
|
||||||
case ASYNC_WRITE_REMAIN: {
|
case ASYNC_WRITE_REMAIN: {
|
||||||
struct clipboard_send *ctx = malloc(sizeof(*ctx));
|
struct clipboard_send *ctx = xmalloc(sizeof(*ctx));
|
||||||
*ctx = (struct clipboard_send) {
|
*ctx = (struct clipboard_send) {
|
||||||
.data = strdup(selection),
|
.data = xstrdup(selection),
|
||||||
.len = len,
|
.len = len,
|
||||||
.idx = async_idx,
|
.idx = async_idx,
|
||||||
};
|
};
|
||||||
|
|
@ -953,7 +954,7 @@ begin_receive_clipboard(struct terminal *term, int read_fd,
|
||||||
return done(user);
|
return done(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct clipboard_receive *ctx = malloc(sizeof(*ctx));
|
struct clipboard_receive *ctx = xmalloc(sizeof(*ctx));
|
||||||
*ctx = (struct clipboard_receive) {
|
*ctx = (struct clipboard_receive) {
|
||||||
.cb = cb,
|
.cb = cb,
|
||||||
.done = done,
|
.done = done,
|
||||||
|
|
|
||||||
18
server.c
18
server.c
|
|
@ -19,6 +19,7 @@
|
||||||
#include "shm.h"
|
#include "shm.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "wayland.h"
|
#include "wayland.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
struct client;
|
struct client;
|
||||||
struct server {
|
struct server {
|
||||||
|
|
@ -157,7 +158,7 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DBG("total len: %u", total_len);
|
LOG_DBG("total len: %u", total_len);
|
||||||
client->buffer.data = malloc(total_len + 1);
|
client->buffer.data = xmalloc(total_len + 1);
|
||||||
client->buffer.left = total_len;
|
client->buffer.left = total_len;
|
||||||
client->buffer.idx = 0;
|
client->buffer.idx = 0;
|
||||||
|
|
||||||
|
|
@ -277,7 +278,7 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data)
|
||||||
memcpy(&argc, p, sizeof(argc));
|
memcpy(&argc, p, sizeof(argc));
|
||||||
p += sizeof(argc);
|
p += sizeof(argc);
|
||||||
|
|
||||||
argv = calloc(argc + 1, sizeof(argv[0]));
|
argv = xcalloc(argc + 1, sizeof(argv[0]));
|
||||||
LOG_DBG("argc = %d", argc);
|
LOG_DBG("argc = %d", argc);
|
||||||
|
|
||||||
for (int i = 0; i < argc; i++) {
|
for (int i = 0; i < argc; i++) {
|
||||||
|
|
@ -302,11 +303,11 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data)
|
||||||
|
|
||||||
client->conf = *server->conf;
|
client->conf = *server->conf;
|
||||||
client->conf.term = strlen(term_env) > 0
|
client->conf.term = strlen(term_env) > 0
|
||||||
? strdup(term_env) : strdup(server->conf->term);
|
? xstrdup(term_env) : xstrdup(server->conf->term);
|
||||||
client->conf.title = strlen(title) > 0
|
client->conf.title = strlen(title) > 0
|
||||||
? strdup(title) : strdup(server->conf->title);
|
? xstrdup(title) : xstrdup(server->conf->title);
|
||||||
client->conf.app_id = strlen(app_id) > 0
|
client->conf.app_id = strlen(app_id) > 0
|
||||||
? strdup(app_id) : strdup(server->conf->app_id);
|
? xstrdup(app_id) : xstrdup(server->conf->app_id);
|
||||||
client->conf.hold_at_exit = hold;
|
client->conf.hold_at_exit = hold;
|
||||||
client->conf.login_shell = login_shell;
|
client->conf.login_shell = login_shell;
|
||||||
|
|
||||||
|
|
@ -360,7 +361,7 @@ fdm_server(struct fdm *fdm, int fd, int events, void *data)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct client *client = malloc(sizeof(*client));
|
struct client *client = xmalloc(sizeof(*client));
|
||||||
*client = (struct client) {
|
*client = (struct client) {
|
||||||
.server = server,
|
.server = server,
|
||||||
.fd = client_fd,
|
.fd = client_fd,
|
||||||
|
|
@ -451,6 +452,11 @@ server_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
||||||
}
|
}
|
||||||
|
|
||||||
server = malloc(sizeof(*server));
|
server = malloc(sizeof(*server));
|
||||||
|
if (unlikely(server == NULL)) {
|
||||||
|
LOG_ERRNO("malloc() failed");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
*server = (struct server) {
|
*server = (struct server) {
|
||||||
.conf = conf,
|
.conf = conf,
|
||||||
.fdm = fdm,
|
.fdm = fdm,
|
||||||
|
|
|
||||||
3
shm.c
3
shm.c
|
|
@ -23,6 +23,7 @@
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
#define TIME_SCROLL 0
|
#define TIME_SCROLL 0
|
||||||
|
|
||||||
|
|
@ -150,7 +151,7 @@ instantiate_offset(struct wl_shm *shm, struct buffer *buf, off_t new_offset)
|
||||||
|
|
||||||
void *mmapped = MAP_FAILED;
|
void *mmapped = MAP_FAILED;
|
||||||
struct wl_buffer *wl_buf = NULL;
|
struct wl_buffer *wl_buf = NULL;
|
||||||
pixman_image_t **pix = calloc(buf->pix_instances, sizeof(*pix));
|
pixman_image_t **pix = xcalloc(buf->pix_instances, sizeof(*pix));
|
||||||
|
|
||||||
mmapped = (uint8_t *)buf->real_mmapped + new_offset;
|
mmapped = (uint8_t *)buf->real_mmapped + new_offset;
|
||||||
|
|
||||||
|
|
|
||||||
17
sixel.c
17
sixel.c
|
|
@ -9,6 +9,7 @@
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "sixel-hls.h"
|
#include "sixel-hls.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
static size_t count;
|
static size_t count;
|
||||||
|
|
||||||
|
|
@ -38,13 +39,13 @@ sixel_init(struct terminal *term)
|
||||||
term->sixel.param = 0;
|
term->sixel.param = 0;
|
||||||
term->sixel.param_idx = 0;
|
term->sixel.param_idx = 0;
|
||||||
memset(term->sixel.params, 0, sizeof(term->sixel.params));
|
memset(term->sixel.params, 0, sizeof(term->sixel.params));
|
||||||
term->sixel.image.data = malloc(1 * 6 * sizeof(term->sixel.image.data[0]));
|
term->sixel.image.data = xmalloc(1 * 6 * sizeof(term->sixel.image.data[0]));
|
||||||
term->sixel.image.width = 1;
|
term->sixel.image.width = 1;
|
||||||
term->sixel.image.height = 6;
|
term->sixel.image.height = 6;
|
||||||
term->sixel.image.autosize = true;
|
term->sixel.image.autosize = true;
|
||||||
|
|
||||||
if (term->sixel.palette == NULL) {
|
if (term->sixel.palette == NULL) {
|
||||||
term->sixel.palette = calloc(
|
term->sixel.palette = xcalloc(
|
||||||
term->sixel.palette_size, sizeof(term->sixel.palette[0]));
|
term->sixel.palette_size, sizeof(term->sixel.palette[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -240,7 +241,7 @@ sixel_overwrite(struct terminal *term, struct sixel *six,
|
||||||
.cols = six->cols,
|
.cols = six->cols,
|
||||||
.pos = six->pos,
|
.pos = six->pos,
|
||||||
};
|
};
|
||||||
imgs[0].data = malloc(imgs[0].width * imgs[0].height * sizeof(uint32_t));
|
imgs[0].data = xmalloc(imgs[0].width * imgs[0].height * sizeof(uint32_t));
|
||||||
memcpy(imgs[0].data, six->data, imgs[0].width * imgs[0].height * sizeof(uint32_t));
|
memcpy(imgs[0].data, six->data, imgs[0].width * imgs[0].height * sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -254,7 +255,7 @@ sixel_overwrite(struct terminal *term, struct sixel *six,
|
||||||
six->pos.col,
|
six->pos.col,
|
||||||
(six->pos.row + rel_below) & (term->grid->num_rows - 1)},
|
(six->pos.row + rel_below) & (term->grid->num_rows - 1)},
|
||||||
};
|
};
|
||||||
imgs[1].data = malloc(imgs[1].width * imgs[1].height * sizeof(uint32_t));
|
imgs[1].data = xmalloc(imgs[1].width * imgs[1].height * sizeof(uint32_t));
|
||||||
memcpy(
|
memcpy(
|
||||||
imgs[1].data,
|
imgs[1].data,
|
||||||
&((const uint32_t *)six->data)[rel_below * term->cell_height * six->width],
|
&((const uint32_t *)six->data)[rel_below * term->cell_height * six->width],
|
||||||
|
|
@ -271,7 +272,7 @@ sixel_overwrite(struct terminal *term, struct sixel *six,
|
||||||
six->pos.col,
|
six->pos.col,
|
||||||
(six->pos.row + rel_above) & (term->grid->num_rows - 1)},
|
(six->pos.row + rel_above) & (term->grid->num_rows - 1)},
|
||||||
};
|
};
|
||||||
imgs[2].data = malloc(imgs[2].width * imgs[2].height * sizeof(uint32_t));
|
imgs[2].data = xmalloc(imgs[2].width * imgs[2].height * sizeof(uint32_t));
|
||||||
for (size_t i = 0; i < imgs[2].height; i++)
|
for (size_t i = 0; i < imgs[2].height; i++)
|
||||||
memcpy(
|
memcpy(
|
||||||
&((uint32_t *)imgs[2].data)[i * imgs[2].width],
|
&((uint32_t *)imgs[2].data)[i * imgs[2].width],
|
||||||
|
|
@ -289,7 +290,7 @@ sixel_overwrite(struct terminal *term, struct sixel *six,
|
||||||
six->pos.col + rel_right,
|
six->pos.col + rel_right,
|
||||||
(six->pos.row + rel_above) & (term->grid->num_rows - 1)},
|
(six->pos.row + rel_above) & (term->grid->num_rows - 1)},
|
||||||
};
|
};
|
||||||
imgs[3].data = malloc(imgs[3].width * imgs[3].height * sizeof(uint32_t));
|
imgs[3].data = xmalloc(imgs[3].width * imgs[3].height * sizeof(uint32_t));
|
||||||
for (size_t i = 0; i < imgs[3].height; i++)
|
for (size_t i = 0; i < imgs[3].height; i++)
|
||||||
memcpy(
|
memcpy(
|
||||||
&((uint32_t *)imgs[3].data)[i * imgs[3].width],
|
&((uint32_t *)imgs[3].data)[i * imgs[3].width],
|
||||||
|
|
@ -464,7 +465,7 @@ sixel_unhook(struct terminal *term)
|
||||||
if (pixel_row_idx == 0)
|
if (pixel_row_idx == 0)
|
||||||
img_data = term->sixel.image.data;
|
img_data = term->sixel.image.data;
|
||||||
else {
|
else {
|
||||||
img_data = malloc(height * stride);
|
img_data = xmalloc(height * stride);
|
||||||
memcpy(
|
memcpy(
|
||||||
img_data,
|
img_data,
|
||||||
&((uint8_t *)term->sixel.image.data)[pixel_row_idx * stride],
|
&((uint8_t *)term->sixel.image.data)[pixel_row_idx * stride],
|
||||||
|
|
@ -566,7 +567,7 @@ resize(struct terminal *term, int new_width, int new_height)
|
||||||
} else {
|
} else {
|
||||||
/* Width (and thus stride) change - need to allocate a new buffer */
|
/* Width (and thus stride) change - need to allocate a new buffer */
|
||||||
assert(new_width > old_width);
|
assert(new_width > old_width);
|
||||||
new_data = malloc(alloc_new_width * alloc_new_height * sizeof(uint32_t));
|
new_data = xmalloc(alloc_new_width * alloc_new_height * sizeof(uint32_t));
|
||||||
|
|
||||||
/* Copy old rows, and initialize new columns to background color */
|
/* Copy old rows, and initialize new columns to background color */
|
||||||
for (int r = 0; r < old_height; r++) {
|
for (int r = 0; r < old_height; r++) {
|
||||||
|
|
|
||||||
9
slave.c
9
slave.c
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "tokenize.h"
|
#include "tokenize.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
is_valid_shell(const char *shell)
|
is_valid_shell(const char *shell)
|
||||||
|
|
@ -217,9 +218,9 @@ slave_exec(int ptmx, char *argv[], int err_fd, bool login_shell,
|
||||||
|
|
||||||
const char *file;
|
const char *file;
|
||||||
if (login_shell) {
|
if (login_shell) {
|
||||||
file = strdup(argv[0]);
|
file = xstrdup(argv[0]);
|
||||||
|
|
||||||
char *arg0 = malloc(strlen(argv[0]) + 1 + 1);
|
char *arg0 = xmalloc(strlen(argv[0]) + 1 + 1);
|
||||||
arg0[0] = '-';
|
arg0[0] = '-';
|
||||||
arg0[1] = '\0';
|
arg0[1] = '\0';
|
||||||
strcat(arg0, argv[0]);
|
strcat(arg0, argv[0]);
|
||||||
|
|
@ -291,7 +292,7 @@ slave_spawn(int ptmx, int argc, const char *cwd, char *const *argv,
|
||||||
char **shell_argv = NULL;
|
char **shell_argv = NULL;
|
||||||
|
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
char *shell_copy = strdup(conf_shell);
|
char *shell_copy = xstrdup(conf_shell);
|
||||||
if (!tokenize_cmdline(shell_copy, &_shell_argv)) {
|
if (!tokenize_cmdline(shell_copy, &_shell_argv)) {
|
||||||
free(shell_copy);
|
free(shell_copy);
|
||||||
(void)!write(fork_pipe[1], &errno, sizeof(errno));
|
(void)!write(fork_pipe[1], &errno, sizeof(errno));
|
||||||
|
|
@ -302,7 +303,7 @@ slave_spawn(int ptmx, int argc, const char *cwd, char *const *argv,
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
for (; argv[count] != NULL; count++)
|
for (; argv[count] != NULL; count++)
|
||||||
;
|
;
|
||||||
shell_argv = malloc((count + 1) * sizeof(shell_argv[0]));
|
shell_argv = xmalloc((count + 1) * sizeof(shell_argv[0]));
|
||||||
for (size_t i = 0; i < count; i++)
|
for (size_t i = 0; i < count; i++)
|
||||||
shell_argv[i] = argv[i];
|
shell_argv[i] = argv[i];
|
||||||
shell_argv[count] = NULL;
|
shell_argv[count] = NULL;
|
||||||
|
|
|
||||||
21
terminal.c
21
terminal.c
|
|
@ -33,6 +33,7 @@
|
||||||
#include "spawn.h"
|
#include "spawn.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "vt.h"
|
#include "vt.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
#define PTMX_TIMING 0
|
#define PTMX_TIMING 0
|
||||||
|
|
||||||
|
|
@ -93,7 +94,7 @@ enqueue_data:
|
||||||
* handler take care of it
|
* handler take care of it
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
void *copy = malloc(len);
|
void *copy = xmalloc(len);
|
||||||
memcpy(copy, _data, len);
|
memcpy(copy, _data, len);
|
||||||
|
|
||||||
struct ptmx_buffer queued = {
|
struct ptmx_buffer queued = {
|
||||||
|
|
@ -510,11 +511,11 @@ initialize_render_workers(struct terminal *term)
|
||||||
goto err_sem_destroy;
|
goto err_sem_destroy;
|
||||||
}
|
}
|
||||||
|
|
||||||
term->render.workers.threads = calloc(
|
term->render.workers.threads = xcalloc(
|
||||||
term->render.workers.count, sizeof(term->render.workers.threads[0]));
|
term->render.workers.count, sizeof(term->render.workers.threads[0]));
|
||||||
|
|
||||||
for (size_t i = 0; i < term->render.workers.count; i++) {
|
for (size_t i = 0; i < term->render.workers.count; i++) {
|
||||||
struct render_worker_context *ctx = malloc(sizeof(*ctx));
|
struct render_worker_context *ctx = xmalloc(sizeof(*ctx));
|
||||||
*ctx = (struct render_worker_context) {
|
*ctx = (struct render_worker_context) {
|
||||||
.term = term,
|
.term = term,
|
||||||
.my_id = 1 + i,
|
.my_id = 1 + i,
|
||||||
|
|
@ -685,7 +686,7 @@ reload_fonts(struct terminal *term)
|
||||||
snprintf(size, sizeof(size), ":size=%.2f", term->font_sizes[i].pt_size);
|
snprintf(size, sizeof(size), ":size=%.2f", term->font_sizes[i].pt_size);
|
||||||
|
|
||||||
size_t len = strlen(it->item.pattern) + strlen(size) + 1;
|
size_t len = strlen(it->item.pattern) + strlen(size) + 1;
|
||||||
names[i] = malloc(len);
|
names[i] = xmalloc(len);
|
||||||
|
|
||||||
strcpy(names[i], it->item.pattern);
|
strcpy(names[i], it->item.pattern);
|
||||||
strcat(names[i], size);
|
strcat(names[i], size);
|
||||||
|
|
@ -767,6 +768,10 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
||||||
int app_sync_updates_fd = -1;
|
int app_sync_updates_fd = -1;
|
||||||
|
|
||||||
struct terminal *term = malloc(sizeof(*term));
|
struct terminal *term = malloc(sizeof(*term));
|
||||||
|
if (unlikely(term == NULL)) {
|
||||||
|
LOG_ERRNO("malloc() failed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if ((ptmx = posix_openpt(O_RDWR | O_NOCTTY)) == -1) {
|
if ((ptmx = posix_openpt(O_RDWR | O_NOCTTY)) == -1) {
|
||||||
LOG_ERRNO("failed to open PTY");
|
LOG_ERRNO("failed to open PTY");
|
||||||
|
|
@ -836,7 +841,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
||||||
.quit = false,
|
.quit = false,
|
||||||
.ptmx = ptmx,
|
.ptmx = ptmx,
|
||||||
.ptmx_buffer = tll_init(),
|
.ptmx_buffer = tll_init(),
|
||||||
.font_sizes = malloc(sizeof(term->font_sizes[0]) * tll_length(conf->fonts)),
|
.font_sizes = xmalloc(sizeof(term->font_sizes[0]) * tll_length(conf->fonts)),
|
||||||
.font_dpi = 0.,
|
.font_dpi = 0.,
|
||||||
.font_subpixel = (conf->colors.alpha == 0xffff /* Can't do subpixel rendering on transparent background */
|
.font_subpixel = (conf->colors.alpha == 0xffff /* Can't do subpixel rendering on transparent background */
|
||||||
? FCFT_SUBPIXEL_DEFAULT
|
? FCFT_SUBPIXEL_DEFAULT
|
||||||
|
|
@ -929,8 +934,8 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
||||||
.hold_at_exit = conf->hold_at_exit,
|
.hold_at_exit = conf->hold_at_exit,
|
||||||
.shutdown_cb = shutdown_cb,
|
.shutdown_cb = shutdown_cb,
|
||||||
.shutdown_data = shutdown_data,
|
.shutdown_data = shutdown_data,
|
||||||
.foot_exe = strdup(foot_exe),
|
.foot_exe = xstrdup(foot_exe),
|
||||||
.cwd = strdup(cwd),
|
.cwd = xstrdup(cwd),
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -2228,7 +2233,7 @@ void
|
||||||
term_set_window_title(struct terminal *term, const char *title)
|
term_set_window_title(struct terminal *term, const char *title)
|
||||||
{
|
{
|
||||||
free(term->window_title);
|
free(term->window_title);
|
||||||
term->window_title = strdup(title);
|
term->window_title = xstrdup(title);
|
||||||
render_refresh_title(term);
|
render_refresh_title(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
3
vt.c
3
vt.c
|
|
@ -13,6 +13,7 @@
|
||||||
#include "grid.h"
|
#include "grid.h"
|
||||||
#include "osc.h"
|
#include "osc.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
#define UNHANDLED() LOG_DBG("unhandled: %s", esc_as_string(term, final))
|
#define UNHANDLED() LOG_DBG("unhandled: %s", esc_as_string(term, final))
|
||||||
|
|
||||||
|
|
@ -649,7 +650,7 @@ action_utf8_print(struct terminal *term, wchar_t wc)
|
||||||
|
|
||||||
if (term->composed_count < CELL_COMB_CHARS_HI) {
|
if (term->composed_count < CELL_COMB_CHARS_HI) {
|
||||||
term->composed_count++;
|
term->composed_count++;
|
||||||
term->composed = realloc(term->composed, term->composed_count * sizeof(term->composed[0]));
|
term->composed = xrealloc(term->composed, term->composed_count * sizeof(term->composed[0]));
|
||||||
term->composed[term->composed_count - 1] = new_cc;
|
term->composed[term->composed_count - 1] = new_cc;
|
||||||
|
|
||||||
term_print(term, CELL_COMB_CHARS_LO + term->composed_count - 1, base_width);
|
term_print(term, CELL_COMB_CHARS_LO + term->composed_count - 1, base_width);
|
||||||
|
|
|
||||||
15
wayland.c
15
wayland.c
|
|
@ -29,6 +29,7 @@
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "selection.h"
|
#include "selection.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
csd_instantiate(struct wl_window *win)
|
csd_instantiate(struct wl_window *win)
|
||||||
|
|
@ -250,7 +251,7 @@ seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name)
|
||||||
{
|
{
|
||||||
struct seat *seat = data;
|
struct seat *seat = data;
|
||||||
free(seat->name);
|
free(seat->name);
|
||||||
seat->name = strdup(name);
|
seat->name = xstrdup(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_seat_listener seat_listener = {
|
static const struct wl_seat_listener seat_listener = {
|
||||||
|
|
@ -318,8 +319,8 @@ output_geometry(void *data, struct wl_output *wl_output, int32_t x, int32_t y,
|
||||||
mon->dim.mm.width = physical_width;
|
mon->dim.mm.width = physical_width;
|
||||||
mon->dim.mm.height = physical_height;
|
mon->dim.mm.height = physical_height;
|
||||||
mon->inch = sqrt(pow(mon->dim.mm.width, 2) + pow(mon->dim.mm.height, 2)) * 0.03937008;
|
mon->inch = sqrt(pow(mon->dim.mm.width, 2) + pow(mon->dim.mm.height, 2)) * 0.03937008;
|
||||||
mon->make = make != NULL ? strdup(make) : NULL;
|
mon->make = make != NULL ? xstrdup(make) : NULL;
|
||||||
mon->model = model != NULL ? strdup(model) : NULL;
|
mon->model = model != NULL ? xstrdup(model) : NULL;
|
||||||
mon->subpixel = subpixel;
|
mon->subpixel = subpixel;
|
||||||
output_update_ppi(mon);
|
output_update_ppi(mon);
|
||||||
}
|
}
|
||||||
|
|
@ -389,7 +390,7 @@ xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
struct monitor *mon = data;
|
struct monitor *mon = data;
|
||||||
mon->name = name != NULL ? strdup(name) : NULL;
|
mon->name = name != NULL ? xstrdup(name) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -397,7 +398,7 @@ xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg_output,
|
||||||
const char *description)
|
const char *description)
|
||||||
{
|
{
|
||||||
struct monitor *mon = data;
|
struct monitor *mon = data;
|
||||||
mon->description = description != NULL ? strdup(description) : NULL;
|
mon->description = description != NULL ? xstrdup(description) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct zxdg_output_v1_listener xdg_output_listener = {
|
static const struct zxdg_output_v1_listener xdg_output_listener = {
|
||||||
|
|
@ -973,7 +974,7 @@ fdm_wayl(struct fdm *fdm, int fd, int events, void *data)
|
||||||
struct wayland *
|
struct wayland *
|
||||||
wayl_init(const struct config *conf, struct fdm *fdm)
|
wayl_init(const struct config *conf, struct fdm *fdm)
|
||||||
{
|
{
|
||||||
struct wayland *wayl = calloc(1, sizeof(*wayl));
|
struct wayland *wayl = xcalloc(1, sizeof(*wayl));
|
||||||
wayl->conf = conf;
|
wayl->conf = conf;
|
||||||
wayl->fdm = fdm;
|
wayl->fdm = fdm;
|
||||||
wayl->fd = -1;
|
wayl->fd = -1;
|
||||||
|
|
@ -1130,7 +1131,7 @@ wayl_win_init(struct terminal *term)
|
||||||
struct wayland *wayl = term->wl;
|
struct wayland *wayl = term->wl;
|
||||||
const struct config *conf = term->conf;
|
const struct config *conf = term->conf;
|
||||||
|
|
||||||
struct wl_window *win = calloc(1, sizeof(*win));
|
struct wl_window *win = xcalloc(1, sizeof(*win));
|
||||||
win->term = term;
|
win->term = term;
|
||||||
win->use_csd = CSD_UNKNOWN;
|
win->use_csd = CSD_UNKNOWN;
|
||||||
win->csd.move_timeout_fd = -1;
|
win->csd.move_timeout_fd = -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue