1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Do not call memcpy if copying nothing

c.f.
* e7b18ca6d9
* 34e1079aef
This commit is contained in:
Nobuyoshi Nakada 2019-05-17 10:25:34 +09:00
parent 32e8b42852
commit b1b385465e
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -1749,6 +1749,15 @@ rb_alloc_tmp_buffer2(volatile VALUE *store, long count, size_t elsize)
#define MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(size_t)(n))
#define MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(size_t)(n))
#define MEMCMP(p1,p2,type,n) memcmp((p1), (p2), sizeof(type)*(size_t)(n))
#ifdef __GLIBC__
static inline void *
ruby_nonempty_memcpy(void *dest, const void *src, size_t n)
{
/* if nothing to be copied, src may be NULL */
return (n ? memcpy(dest, src, n) : dest);
}
#define memcpy(p1,p2,n) ruby_nonempty_memcpy(p1, p2, n)
#endif
void rb_obj_infect(VALUE victim, VALUE carrier);