ensure command alignment is correct
This commit is contained in:
parent
38bd9b3326
commit
ad1bdf56e3
|
@ -1,4 +1,5 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdalign.h>
|
||||||
#include "rencache.h"
|
#include "rencache.h"
|
||||||
|
|
||||||
/* a cache over the software renderer -- all drawing operations are stored as
|
/* a cache over the software renderer -- all drawing operations are stored as
|
||||||
|
@ -78,6 +79,8 @@ static RenRect merge_rects(RenRect a, RenRect b) {
|
||||||
|
|
||||||
|
|
||||||
static Command* push_command(int type, int size) {
|
static Command* push_command(int type, int size) {
|
||||||
|
size_t alignment = alignof(max_align_t) - 1;
|
||||||
|
size = (size + alignment) & ~alignment;
|
||||||
Command *cmd = (Command*) (command_buf + command_buf_idx);
|
Command *cmd = (Command*) (command_buf + command_buf_idx);
|
||||||
int n = command_buf_idx + size;
|
int n = command_buf_idx + size;
|
||||||
if (n > COMMAND_BUF_SIZE) {
|
if (n > COMMAND_BUF_SIZE) {
|
||||||
|
|
Loading…
Reference in New Issue