Use os_memdup()
This leads to cleaner code overall, and also reduces the size of the hostapd and wpa_supplicant binaries (in hwsim test build on x86_64) by about 2.5 and 3.5KiB respectively. The mechanical conversions all over the code were done with the following spatch: @@ expression SIZE, SRC; expression a; @@ -a = os_malloc(SIZE); +a = os_memdup(SRC, SIZE); <... if (!a) {...} ...> -os_memcpy(a, SRC, SIZE); Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
dbdda355d0
commit
a1f11e34c4
73 changed files with 201 additions and 376 deletions
|
@ -71,13 +71,12 @@ static void * eap_mschapv2_init(struct eap_sm *sm)
|
|||
}
|
||||
|
||||
if (sm->peer_challenge) {
|
||||
data->peer_challenge = os_malloc(CHALLENGE_LEN);
|
||||
data->peer_challenge = os_memdup(sm->peer_challenge,
|
||||
CHALLENGE_LEN);
|
||||
if (data->peer_challenge == NULL) {
|
||||
os_free(data);
|
||||
return NULL;
|
||||
}
|
||||
os_memcpy(data->peer_challenge, sm->peer_challenge,
|
||||
CHALLENGE_LEN);
|
||||
}
|
||||
|
||||
return data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue