mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-25 01:40:19 -05: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
10
extract.c
10
extract.c
|
|
@ -20,6 +20,11 @@ struct extraction_context *
|
|||
extract_begin(enum selection_kind kind)
|
||||
{
|
||||
struct extraction_context *ctx = malloc(sizeof(*ctx));
|
||||
if (unlikely(ctx == NULL)) {
|
||||
LOG_ERRNO("malloc() failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*ctx = (struct extraction_context){
|
||||
.selection_kind = kind,
|
||||
};
|
||||
|
|
@ -80,6 +85,11 @@ extract_finish(struct extraction_context *ctx, char **text, size_t *len)
|
|||
}
|
||||
|
||||
*text = malloc(_len + 1);
|
||||
if (unlikely(text == NULL)) {
|
||||
LOG_ERRNO("malloc() failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
wcstombs(*text, ctx->buf, _len + 1);
|
||||
|
||||
if (len != NULL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue