diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2021-04-27 16:19:21 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2021-04-27 16:26:27 +0200 |
commit | 8247667a3ee0d86f26094e722497b0cbb99cc12b (patch) | |
tree | d03fb75cca2ad4dd63d3c55e1d6ecde074441182 /drivers | |
parent | 288f484d0a034d02fbca3db0a2f14f5a0084a36b (diff) |
Core: Drop custom `copymem`/`zeromem` defines
We've been using standard C library functions `memcpy`/`memset` for these since
2016 with 67f65f66391327b2967a20a89c3627e1dd6e84eb.
There was still the possibility for third-party platform ports to override the
definitions with a custom header, but this doesn't seem useful anymore.
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/coreaudio/audio_driver_coreaudio.cpp | 22 | ||||
-rw-r--r-- | drivers/png/image_loader_png.cpp | 2 | ||||
-rw-r--r-- | drivers/png/png_driver_common.cpp | 4 | ||||
-rw-r--r-- | drivers/unix/net_socket_posix.cpp | 10 | ||||
-rw-r--r-- | drivers/vulkan/rendering_device_vulkan.cpp | 10 |
5 files changed, 24 insertions, 24 deletions
diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp index f40036d628..4139727422 100644 --- a/drivers/coreaudio/audio_driver_coreaudio.cpp +++ b/drivers/coreaudio/audio_driver_coreaudio.cpp @@ -70,7 +70,7 @@ OSStatus AudioDriverCoreAudio::output_device_address_cb(AudioObjectID inObjectID Error AudioDriverCoreAudio::init() { AudioComponentDescription desc; - zeromem(&desc, sizeof(desc)); + memset(&desc, 0, sizeof(desc)); desc.componentType = kAudioUnitType_Output; #ifdef OSX_ENABLED desc.componentSubType = kAudioUnitSubType_HALOutput; @@ -97,7 +97,7 @@ Error AudioDriverCoreAudio::init() { AudioStreamBasicDescription strdesc; - zeromem(&strdesc, sizeof(strdesc)); + memset(&strdesc, 0, sizeof(strdesc)); UInt32 size = sizeof(strdesc); result = AudioUnitGetProperty(audio_unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, kOutputBus, &strdesc, &size); ERR_FAIL_COND_V(result != noErr, FAILED); @@ -118,7 +118,7 @@ Error AudioDriverCoreAudio::init() { mix_rate = GLOBAL_GET("audio/driver/mix_rate"); - zeromem(&strdesc, sizeof(strdesc)); + memset(&strdesc, 0, sizeof(strdesc)); strdesc.mFormatID = kAudioFormatLinearPCM; strdesc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked; strdesc.mChannelsPerFrame = channels; @@ -148,7 +148,7 @@ Error AudioDriverCoreAudio::init() { print_verbose("CoreAudio: audio buffer frames: " + itos(buffer_frames) + " calculated latency: " + itos(buffer_frames * 1000 / mix_rate) + "ms"); AURenderCallbackStruct callback; - zeromem(&callback, sizeof(AURenderCallbackStruct)); + memset(&callback, 0, sizeof(AURenderCallbackStruct)); callback.inputProc = &AudioDriverCoreAudio::output_callback; callback.inputProcRefCon = this; result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, kOutputBus, &callback, sizeof(callback)); @@ -173,7 +173,7 @@ OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon, if (!ad->active || !ad->try_lock()) { for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) { AudioBuffer *abuf = &ioData->mBuffers[i]; - zeromem(abuf->mData, abuf->mDataByteSize); + memset(abuf->mData, 0, abuf->mDataByteSize); }; return 0; }; @@ -293,7 +293,7 @@ void AudioDriverCoreAudio::finish() { lock(); AURenderCallbackStruct callback; - zeromem(&callback, sizeof(AURenderCallbackStruct)); + memset(&callback, 0, sizeof(AURenderCallbackStruct)); result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, kOutputBus, &callback, sizeof(callback)); if (result != noErr) { ERR_PRINT("AudioUnitSetProperty failed"); @@ -337,7 +337,7 @@ void AudioDriverCoreAudio::finish() { Error AudioDriverCoreAudio::capture_init() { AudioComponentDescription desc; - zeromem(&desc, sizeof(desc)); + memset(&desc, 0, sizeof(desc)); desc.componentType = kAudioUnitType_Output; #ifdef OSX_ENABLED desc.componentSubType = kAudioUnitSubType_HALOutput; @@ -383,7 +383,7 @@ Error AudioDriverCoreAudio::capture_init() { #endif AudioStreamBasicDescription strdesc; - zeromem(&strdesc, sizeof(strdesc)); + memset(&strdesc, 0, sizeof(strdesc)); size = sizeof(strdesc); result = AudioUnitGetProperty(input_unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, kInputBus, &strdesc, &size); ERR_FAIL_COND_V(result != noErr, FAILED); @@ -405,7 +405,7 @@ Error AudioDriverCoreAudio::capture_init() { mix_rate = GLOBAL_GET("audio/driver/mix_rate"); - zeromem(&strdesc, sizeof(strdesc)); + memset(&strdesc, 0, sizeof(strdesc)); strdesc.mFormatID = kAudioFormatLinearPCM; strdesc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked; strdesc.mChannelsPerFrame = capture_channels; @@ -419,7 +419,7 @@ Error AudioDriverCoreAudio::capture_init() { ERR_FAIL_COND_V(result != noErr, FAILED); AURenderCallbackStruct callback; - zeromem(&callback, sizeof(AURenderCallbackStruct)); + memset(&callback, 0, sizeof(AURenderCallbackStruct)); callback.inputProc = &AudioDriverCoreAudio::input_callback; callback.inputProcRefCon = this; result = AudioUnitSetProperty(input_unit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, kInputBus, &callback, sizeof(callback)); @@ -436,7 +436,7 @@ void AudioDriverCoreAudio::capture_finish() { lock(); AURenderCallbackStruct callback; - zeromem(&callback, sizeof(AURenderCallbackStruct)); + memset(&callback, 0, sizeof(AURenderCallbackStruct)); OSStatus result = AudioUnitSetProperty(input_unit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, 0, &callback, sizeof(callback)); if (result != noErr) { ERR_PRINT("AudioUnitSetProperty failed"); diff --git a/drivers/png/image_loader_png.cpp b/drivers/png/image_loader_png.cpp index 854c6706e6..ded6bbc53e 100644 --- a/drivers/png/image_loader_png.cpp +++ b/drivers/png/image_loader_png.cpp @@ -88,7 +88,7 @@ Vector<uint8_t> ImageLoaderPNG::lossless_pack_png(const Ref<Image> &p_image) { { // must be closed before call to image_to_png uint8_t *writer = out_buffer.ptrw(); - copymem(writer, "PNG ", 4); + memcpy(writer, "PNG ", 4); } Error err = PNGDriverCommon::image_to_png(p_image, out_buffer); diff --git a/drivers/png/png_driver_common.cpp b/drivers/png/png_driver_common.cpp index 9e848a2253..412e17c6b7 100644 --- a/drivers/png/png_driver_common.cpp +++ b/drivers/png/png_driver_common.cpp @@ -60,7 +60,7 @@ static bool check_error(const png_image &image) { Error png_to_image(const uint8_t *p_source, size_t p_size, bool p_force_linear, Ref<Image> p_image) { png_image png_img; - zeromem(&png_img, sizeof(png_img)); + memset(&png_img, 0, sizeof(png_img)); png_img.version = PNG_IMAGE_VERSION; // fetch image properties @@ -134,7 +134,7 @@ Error image_to_png(const Ref<Image> &p_image, Vector<uint8_t> &p_buffer) { ERR_FAIL_COND_V(source_image->is_compressed(), FAILED); png_image png_img; - zeromem(&png_img, sizeof(png_img)); + memset(&png_img, 0, sizeof(png_img)); png_img.version = PNG_IMAGE_VERSION; png_img.width = source_image->get_width(); png_img.height = source_image->get_height(); diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp index bbf96d8239..e2ad352c10 100644 --- a/drivers/unix/net_socket_posix.cpp +++ b/drivers/unix/net_socket_posix.cpp @@ -106,7 +106,7 @@ size_t NetSocketPosix::_set_addr_storage(struct sockaddr_storage *p_addr, const addr6->sin6_family = AF_INET6; addr6->sin6_port = htons(p_port); if (p_ip.is_valid()) { - copymem(&addr6->sin6_addr.s6_addr, p_ip.get_ipv6(), 16); + memcpy(&addr6->sin6_addr.s6_addr, p_ip.get_ipv6(), 16); } else { addr6->sin6_addr = in6addr_any; } @@ -121,7 +121,7 @@ size_t NetSocketPosix::_set_addr_storage(struct sockaddr_storage *p_addr, const addr4->sin_port = htons(p_port); // short, network byte order if (p_ip.is_valid()) { - copymem(&addr4->sin_addr.s_addr, p_ip.get_ipv4(), 4); + memcpy(&addr4->sin_addr.s_addr, p_ip.get_ipv4(), 4); } else { addr4->sin_addr.s_addr = INADDR_ANY; } @@ -283,13 +283,13 @@ _FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IP_Address p_ip, St ERR_FAIL_COND_V(!if_ip.is_valid(), ERR_INVALID_PARAMETER); struct ip_mreq greq; int sock_opt = p_add ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP; - copymem(&greq.imr_multiaddr, p_ip.get_ipv4(), 4); - copymem(&greq.imr_interface, if_ip.get_ipv4(), 4); + memcpy(&greq.imr_multiaddr, p_ip.get_ipv4(), 4); + memcpy(&greq.imr_interface, if_ip.get_ipv4(), 4); ret = setsockopt(_sock, level, sock_opt, (const char *)&greq, sizeof(greq)); } else { struct ipv6_mreq greq; int sock_opt = p_add ? IPV6_ADD_MEMBERSHIP : IPV6_DROP_MEMBERSHIP; - copymem(&greq.ipv6mr_multiaddr, p_ip.get_ipv6(), 16); + memcpy(&greq.ipv6mr_multiaddr, p_ip.get_ipv6(), 16); greq.ipv6mr_interface = if_v6id; ret = setsockopt(_sock, level, sock_opt, (const char *)&greq, sizeof(greq)); } diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 09e2b4546a..b664ccdd3c 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -1600,7 +1600,7 @@ Error RenderingDeviceVulkan::_buffer_update(Buffer *p_buffer, size_t p_offset, c } //copy to staging buffer - copymem(((uint8_t *)data_ptr) + block_write_offset, p_data + submit_from, block_write_amount); + memcpy(((uint8_t *)data_ptr) + block_write_offset, p_data + submit_from, block_write_amount); //unmap vmaUnmapMemory(allocator, staging_buffer_blocks[staging_buffer_current].allocation); @@ -2558,7 +2558,7 @@ Vector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture *tex const uint8_t *rptr = slice_read_ptr + y * layout.rowPitch; uint8_t *wptr = write_ptr + y * line_width; - copymem(wptr, rptr, line_width); + memcpy(wptr, rptr, line_width); } } else { @@ -2566,7 +2566,7 @@ Vector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture *tex for (uint32_t y = 0; y < height; y++) { const uint8_t *rptr = slice_read_ptr + y * layout.rowPitch; uint8_t *wptr = write_ptr + y * pixel_size * width; - copymem(wptr, rptr, (uint64_t)pixel_size * width); + memcpy(wptr, rptr, (uint64_t)pixel_size * width); } } } @@ -2699,7 +2699,7 @@ Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t { buffer_data.resize(buffer_size); uint8_t *w = buffer_data.ptrw(); - copymem(w, buffer_mem, buffer_size); + memcpy(w, buffer_mem, buffer_size); } vmaUnmapMemory(allocator, tmp_buffer.allocation); @@ -5359,7 +5359,7 @@ Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) { { buffer_data.resize(buffer->size); uint8_t *w = buffer_data.ptrw(); - copymem(w, buffer_mem, buffer->size); + memcpy(w, buffer_mem, buffer->size); } vmaUnmapMemory(allocator, tmp_buffer.allocation); |