I think that copying elements of array like this:
unsigned char *new_bytes_array = malloc(sizeof(unsigned char)*length/2);
for(int i=0, j=0; i<length; i++) {
if(i % 2 == 0) continue;
new_bytes_array[j] = old_bytes_array[i];
j++;
}
is making copy but value not by reference, but I would like to make sure that this will be deep copy not just shallow copy of references or pointers.
I know that this is maybe easy and ridiculous qustion, but I cannot find similar on stack rather memcpy() all array, but I want to copy only some elements for example every second element, or copy 1-3 elements and skip 4th element, (if i%4 == 0 skip element).
sizeof (unsigned char)is always 1, so it's just an annoying way to write1(wihch in case of a multiplication is pretty pointless). Consider removing it.sizeof(unsigned char)is not always 1. So I think it's not a good idea to remove it.sizeofis units ofchar, so by definitionsizeof (char)is 1.sizeofis executed in compile time, so I thinksizeof(unsigned char)is better than a magic number1.