user6575913 user6575913 - 15 days ago 5x
C Question

Pointer conversion in c

I have the following lines:

char *name = malloc(strsize + 1);


uint8_t *data;
data = (uint8_t *)name;

It is correct? It doesn't exist a chance that the pointer *name will be interpreted bad when that conversion is done?


That shouldn't be much of a problem, except that the signedness of the memory would be interpreted differently between access along data and name. In most of the practical platforms, the size of char and uint8_t in bits is the same.