update: the point of whether char, signed char, or unsigned was ultimately moot here. it was more appropriate to use memcpy in this situation, since it works indiscriminately on bytes.
Couldn't be a simpler operation, but I seem to be missing a critical step. In the following code, I am attempting to fill bufferdata
with buffer
for which the compiler warns me of a difference in signedness.
unsigned char buffer[4096] = {0};
char *bufferdata;
bufferdata = (char*)malloc(4096 * sizeof(bufferdata));
if (! bufferdata)
return false;
while( ... )
{
// nextBlock( voidp _buffer, unsigned _length );
read=nextBlock( buffer, 4096);
if( read > 0 )
{
bufferdata = strncat(bufferdata, buffer, read); // (help)
// leads to: pointer targets in passing argument 2 of strncat differ in signedness.
if(read == 4096) {
// let's go for another chunk
bufferdata = (char*)realloc(bufferdata, ( strlen(bufferdata) + (4096 * sizeof(bufferdata)) ) );
if (! bufferdata) {
printf("failed to realloc\n");
return false;
}
}
}
else if( read<0 )
{
printf("error.\n");
break;
}
else {
printf("done.\n");
break;
}
}