mirror of
https://github.com/samba-team/samba.git
synced 2025-02-02 09:47:23 +03:00
ctdb: Avoid a talloc in ctdb_queue_send
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
5907b0cc1e
commit
70c79f5140
@ -44,6 +44,7 @@ struct ctdb_queue_pkt {
|
||||
uint8_t *data;
|
||||
uint32_t length;
|
||||
uint32_t full_length;
|
||||
uint8_t buf[];
|
||||
};
|
||||
|
||||
struct ctdb_queue {
|
||||
@ -324,11 +325,13 @@ int ctdb_queue_send(struct ctdb_queue *queue, uint8_t *data, uint32_t length)
|
||||
if (length2 == 0) return 0;
|
||||
}
|
||||
|
||||
pkt = talloc(queue, struct ctdb_queue_pkt);
|
||||
pkt = talloc_size(
|
||||
queue, offsetof(struct ctdb_queue_pkt, buf) + length2);
|
||||
CTDB_NO_MEMORY(queue->ctdb, pkt);
|
||||
talloc_set_name_const(pkt, "struct ctdb_queue_pkt");
|
||||
|
||||
pkt->data = talloc_memdup(pkt, data, length2);
|
||||
CTDB_NO_MEMORY(queue->ctdb, pkt->data);
|
||||
pkt->data = pkt->buf;
|
||||
memcpy(pkt->data, data, length2);
|
||||
|
||||
pkt->length = length2;
|
||||
pkt->full_length = full_length;
|
||||
|
Loading…
x
Reference in New Issue
Block a user