mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
Add the offsetof macro to libctdb
change all calls to new_ctdb_request() to use the offset macro to calculate the correct size (instead of allocating one byte too many and hoping the alignment padding saves us.) (This used to be ctdb commit 07b395258ab08218e8eed3b4a52654925b85275c)
This commit is contained in:
parent
f94291c37d
commit
0844759964
@ -346,7 +346,7 @@ struct ctdb_request *new_ctdb_control_request(struct ctdb_connection *ctdb,
|
||||
struct ctdb_request *req;
|
||||
struct ctdb_req_control *pkt;
|
||||
|
||||
req = new_ctdb_request(sizeof(*pkt) + extra, callback, cbdata);
|
||||
req = new_ctdb_request(offsetof(struct ctdb_req_control, data) + extra, callback, cbdata);
|
||||
if (!req)
|
||||
return NULL;
|
||||
|
||||
@ -632,7 +632,7 @@ ctdb_readrecordlock_send(struct ctdb_db *ctdb_db, TDB_DATA key,
|
||||
lock->held = false;
|
||||
|
||||
/* Get ready in case we need to send a migrate request. */
|
||||
req = new_ctdb_request(sizeof(*req->hdr.call)
|
||||
req = new_ctdb_request(offsetof(struct ctdb_req_call, data)
|
||||
+ key.dsize, callback, cbdata);
|
||||
if (!req) {
|
||||
ctdb_release_lock(lock);
|
||||
|
@ -7,6 +7,10 @@
|
||||
#include <ctdb.h>
|
||||
#include <ctdb_protocol.h>
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(t,f) ((unsigned int)&((t *)0)->f)
|
||||
#endif
|
||||
|
||||
struct message_handler_info;
|
||||
struct ctdb_reply_call;
|
||||
|
||||
|
@ -99,7 +99,7 @@ int ctdb_send_message(struct ctdb_connection *ctdb,
|
||||
struct ctdb_req_message *pkt;
|
||||
|
||||
/* We just discard it once it's finished: no reply. */
|
||||
req = new_ctdb_request(sizeof(*pkt) + data.dsize,
|
||||
req = new_ctdb_request(offsetof(struct ctdb_req_message, data) + data.dsize,
|
||||
ctdb_cancel_callback, NULL);
|
||||
if (!req) {
|
||||
return -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user