I have a question about using cpp memmove().

Asked 2 years ago, Updated 2 years ago, 34 views

Hi, how are you?

I can't use JNI or JNA due to current circumstances

I'm transcribing the cpp code to java

Code is

typedef unsigned char BYTE;

char *Data1; BYTE *Data2; for(... memmove(&Data1[i * 2], &Data2[j], 160);

If it's organized like this, Data1 and Data2's data are given as much as the corresponding length I'm not sure what the indexes in & and [] mean here. Are you saying that you copy the value from Data2[j] by length = 160 with Data1[i*2] as the starting point? I don't know.

c++ java

2022-09-22 18:13

1 Answers

This can be easily found in the references (#1, #2, and #3.

void* memmove(void* dest, const void* src, size_t count);

It looks like this and the action is to copy the count byte of src to the dest.
So in the example you're asking, you're copying 160 bytes from &Data2[j] to &Data1[i*2].
One thing to keep in mind when porting is that even if the dest and src overlap during the copy process, it should work properly.


2022-09-22 18:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.