mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 23:30:28 +01:00
auth-chain: embed copy of permission string in AuthCall
Since the allocated AuthCall struct is small, we can just copy the permission string inside the struct. No need to strdup() the string separately.
This commit is contained in:
parent
89d0fdfa36
commit
4d79e3276b
1 changed files with 7 additions and 7 deletions
|
|
@ -49,7 +49,7 @@ typedef struct {
|
|||
CList auth_call_lst;
|
||||
NMAuthChain *chain;
|
||||
NMAuthManagerCallId *call_id;
|
||||
char *permission;
|
||||
char permission[];
|
||||
} AuthCall;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -74,7 +74,6 @@ auth_call_free (AuthCall *call)
|
|||
if (call->call_id)
|
||||
nm_auth_manager_check_authorization_cancel (call->call_id);
|
||||
c_list_unlink_stale (&call->auth_call_lst);
|
||||
g_free (call->permission);
|
||||
g_slice_free (AuthCall, call);
|
||||
}
|
||||
|
||||
|
|
@ -274,6 +273,7 @@ nm_auth_chain_add_call (NMAuthChain *self,
|
|||
{
|
||||
AuthCall *call;
|
||||
NMAuthManager *auth_manager = nm_auth_manager_get ();
|
||||
gsize l_p_1;
|
||||
|
||||
g_return_if_fail (self);
|
||||
g_return_if_fail (self->subject);
|
||||
|
|
@ -283,11 +283,11 @@ nm_auth_chain_add_call (NMAuthChain *self,
|
|||
nm_assert ( nm_auth_subject_is_unix_process (self->subject)
|
||||
|| nm_auth_subject_is_internal (self->subject));
|
||||
|
||||
call = g_slice_new (AuthCall);
|
||||
*call = (AuthCall) {
|
||||
.chain = self,
|
||||
.permission = g_strdup (permission),
|
||||
};
|
||||
l_p_1 = strlen (permission) + 1;
|
||||
call = g_malloc (sizeof (AuthCall) + l_p_1);
|
||||
call->chain = self;
|
||||
call->call_id = NULL;
|
||||
memcpy (call->permission, permission, l_p_1);
|
||||
c_list_link_tail (&self->auth_call_lst_head, &call->auth_call_lst);
|
||||
call->call_id = nm_auth_manager_check_authorization (auth_manager,
|
||||
self->subject,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue