mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
util/mem: Move memdup to new util/mem.c file
This seems handy and I want to use this in wlr_color_representation.
This commit is contained in:
parent
c14aa1d0b8
commit
f5dc6416f0
4 changed files with 33 additions and 11 deletions
16
util/mem.c
Normal file
16
util/mem.c
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "util/mem.h"
|
||||
|
||||
bool memdup(void *out, const void *src, size_t size) {
|
||||
void *dst = malloc(size);
|
||||
if (dst == NULL) {
|
||||
return false;
|
||||
}
|
||||
memcpy(dst, src, size);
|
||||
void **dst_ptr = out;
|
||||
*dst_ptr = dst;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ wlr_files += files(
|
|||
'global.c',
|
||||
'log.c',
|
||||
'matrix.c',
|
||||
'mem.c',
|
||||
'rect_union.c',
|
||||
'region.c',
|
||||
'set.c',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue