Slight refactoring to reduce code duplication.
This also comes with a performance bump due to inlining of reg_read/reg_write (as they're only called once now) and the unlikely() on CHECK_REG_TYPE.
This commit is contained in:
@@ -129,14 +129,14 @@ static inline void uc_common_init(struct uc_struct* uc)
|
||||
uc->release = release_common;
|
||||
}
|
||||
|
||||
#define CHECK_REG_TYPE(type) do { \
|
||||
if (size) { \
|
||||
if (*size < sizeof(type)) { \
|
||||
return UC_ERR_NOMEM; \
|
||||
} \
|
||||
*size = sizeof(type); \
|
||||
} \
|
||||
ret = UC_ERR_OK; \
|
||||
#define CHECK_REG_TYPE(type) do { \
|
||||
if (unlikely(size)) { \
|
||||
if (unlikely(*size < sizeof(type))) { \
|
||||
return UC_ERR_NOMEM; \
|
||||
} \
|
||||
*size = sizeof(type); \
|
||||
} \
|
||||
ret = UC_ERR_OK; \
|
||||
} while(0)
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user