mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-04-28 06:46:35 -04:00
Move marshal/demarshal buffer into struct wl_closure
This commit is contained in:
parent
f1e7bd384c
commit
9f897988fd
1 changed files with 11 additions and 12 deletions
23
connection.c
23
connection.c
|
|
@ -58,6 +58,7 @@ struct wl_closure {
|
||||||
struct wl_array *array;
|
struct wl_array *array;
|
||||||
} values[20];
|
} values[20];
|
||||||
void *args[20];
|
void *args[20];
|
||||||
|
uint32_t buffer[64];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wl_connection {
|
struct wl_connection {
|
||||||
|
|
@ -335,17 +336,16 @@ wl_connection_vmarshal(struct wl_connection *connection,
|
||||||
uint32_t opcode, va_list ap,
|
uint32_t opcode, va_list ap,
|
||||||
const struct wl_message *message)
|
const struct wl_message *message)
|
||||||
{
|
{
|
||||||
|
struct wl_closure *closure = &connection->closure;
|
||||||
struct wl_object *object;
|
struct wl_object *object;
|
||||||
uint32_t args[32], length, *p, size;
|
uint32_t length, *p, size;
|
||||||
int32_t dup_fd;
|
int32_t dup_fd;
|
||||||
struct wl_array *array;
|
struct wl_array *array;
|
||||||
const char *s;
|
const char *s;
|
||||||
int i, count, fd;
|
int i, count, fd;
|
||||||
|
|
||||||
count = strlen(message->signature);
|
count = strlen(message->signature);
|
||||||
assert(count <= ARRAY_LENGTH(args));
|
p = &closure->buffer[2];
|
||||||
|
|
||||||
p = &args[2];
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
switch (message->signature[i]) {
|
switch (message->signature[i]) {
|
||||||
case 'u':
|
case 'u':
|
||||||
|
|
@ -390,10 +390,10 @@ wl_connection_vmarshal(struct wl_connection *connection,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size = (p - args) * sizeof *p;
|
size = (p - closure->buffer) * sizeof *p;
|
||||||
args[0] = sender->id;
|
closure->buffer[0] = sender->id;
|
||||||
args[1] = opcode | (size << 16);
|
closure->buffer[1] = opcode | (size << 16);
|
||||||
wl_connection_write(connection, args, size);
|
wl_connection_write(connection, closure->buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wl_closure *
|
struct wl_closure *
|
||||||
|
|
@ -405,7 +405,6 @@ wl_connection_demarshal(struct wl_connection *connection,
|
||||||
uint32_t *p, *next, *end, length;
|
uint32_t *p, *next, *end, length;
|
||||||
int i, count;
|
int i, count;
|
||||||
struct wl_object *object;
|
struct wl_object *object;
|
||||||
uint32_t buffer[64];
|
|
||||||
struct wl_closure *closure = &connection->closure;
|
struct wl_closure *closure = &connection->closure;
|
||||||
|
|
||||||
count = strlen(message->signature) + 2;
|
count = strlen(message->signature) + 2;
|
||||||
|
|
@ -414,7 +413,7 @@ wl_connection_demarshal(struct wl_connection *connection,
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sizeof buffer < size) {
|
if (sizeof closure->buffer < size) {
|
||||||
printf("request too big, should malloc tmp buffer here\n");
|
printf("request too big, should malloc tmp buffer here\n");
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
@ -426,8 +425,8 @@ wl_connection_demarshal(struct wl_connection *connection,
|
||||||
closure->types[1] = &ffi_type_pointer;
|
closure->types[1] = &ffi_type_pointer;
|
||||||
closure->args[1] = &closure->values[1];
|
closure->args[1] = &closure->values[1];
|
||||||
|
|
||||||
wl_connection_copy(connection, buffer, size);
|
wl_connection_copy(connection, closure->buffer, size);
|
||||||
p = &buffer[2];
|
p = &closure->buffer[2];
|
||||||
end = (uint32_t *) ((char *) (p + size));
|
end = (uint32_t *) ((char *) (p + size));
|
||||||
for (i = 2; i < count; i++) {
|
for (i = 2; i < count; i++) {
|
||||||
if (p + 1 > end) {
|
if (p + 1 > end) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue