Introduce os_memdup()
This can be used to clean the code and reduce size by converting os_malloc() followed by os_memcpy() cases to use a single function call. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
60be144e45
commit
dbdda355d0
4 changed files with 40 additions and 0 deletions
|
@ -508,6 +508,16 @@ int os_memcmp_const(const void *a, const void *b, size_t len)
|
|||
}
|
||||
|
||||
|
||||
void * os_memdup(const void *src, size_t len)
|
||||
{
|
||||
void *r = os_malloc(len);
|
||||
|
||||
if (r)
|
||||
os_memcpy(r, src, len);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
#ifdef WPA_TRACE
|
||||
|
||||
#if defined(WPA_TRACE_BFD) && defined(CONFIG_TESTING_OPTIONS)
|
||||
|
@ -540,6 +550,8 @@ static int testing_fail_alloc(void)
|
|||
i++;
|
||||
if (i < res && os_strcmp(func[i], "os_strdup") == 0)
|
||||
i++;
|
||||
if (i < res && os_strcmp(func[i], "os_memdup") == 0)
|
||||
i++;
|
||||
|
||||
pos = wpa_trace_fail_func;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue