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
|
@ -126,12 +126,10 @@ static TNC_Result TNC_TNCC_ReportMessageTypes(
|
|||
|
||||
imc = tnc_imc[imcID];
|
||||
os_free(imc->supported_types);
|
||||
imc->supported_types =
|
||||
os_malloc(typeCount * sizeof(TNC_MessageType));
|
||||
imc->supported_types = os_memdup(supportedTypes,
|
||||
typeCount * sizeof(TNC_MessageType));
|
||||
if (imc->supported_types == NULL)
|
||||
return TNC_RESULT_FATAL;
|
||||
os_memcpy(imc->supported_types, supportedTypes,
|
||||
typeCount * sizeof(TNC_MessageType));
|
||||
imc->num_supported_types = typeCount;
|
||||
|
||||
return TNC_RESULT_SUCCESS;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue