mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
common: Add additional memory utilities (xzalloc() etc.)
This commit is contained in:
parent
b89f7bfc0d
commit
cb40cdc36c
35 changed files with 193 additions and 167 deletions
12
src/buffer.c
12
src/buffer.c
|
|
@ -24,12 +24,12 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <drm_fourcc.h>
|
||||
#include <wlr/interfaces/wlr_buffer.h>
|
||||
#include "buffer.h"
|
||||
#include "common/mem.h"
|
||||
|
||||
static const struct wlr_buffer_impl data_buffer_impl;
|
||||
|
||||
|
|
@ -88,10 +88,7 @@ struct lab_data_buffer *
|
|||
buffer_create_cairo(uint32_t width, uint32_t height, float scale,
|
||||
bool free_on_destroy)
|
||||
{
|
||||
struct lab_data_buffer *buffer = calloc(1, sizeof(*buffer));
|
||||
if (!buffer) {
|
||||
return NULL;
|
||||
}
|
||||
struct lab_data_buffer *buffer = xzalloc(sizeof(*buffer));
|
||||
buffer->unscaled_width = width;
|
||||
buffer->unscaled_height = height;
|
||||
width *= scale;
|
||||
|
|
@ -130,10 +127,7 @@ struct lab_data_buffer *
|
|||
buffer_create_wrap(void *pixel_data, uint32_t width, uint32_t height,
|
||||
uint32_t stride, bool free_on_destroy)
|
||||
{
|
||||
struct lab_data_buffer *buffer = calloc(1, sizeof(*buffer));
|
||||
if (!buffer) {
|
||||
return NULL;
|
||||
}
|
||||
struct lab_data_buffer *buffer = xzalloc(sizeof(*buffer));
|
||||
wlr_buffer_init(&buffer->base, &data_buffer_impl, width, height);
|
||||
buffer->data = pixel_data;
|
||||
buffer->format = DRM_FORMAT_ARGB8888;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue