memcpy(buffer,control->gtls_buffer_hack,control->gtls_buffer_hack_len);// Fill their buffer partially
free(control->gtls_buffer_hack);// free our memory, it's not chained anymore
control->gtls_buffer_hack_len=0;// we don't have a hack buffer anymore
if(debug)printf("Did a partial fill to help quench thirst for data\n");
if(debug)
printf("Did a partial fill to help quench thirst for data\n");
}elseif(length<control->gtls_buffer_hack_len){// If it's asking for less...
control->gtls_buffer_hack_len-=length;// subtract what they're asking for
memcpy(buffer,control->gtls_buffer_hack,length);// fill their buffer
hackhackhack=(char*)malloc(sizeof(char)*control->gtls_buffer_hack_len);// strndup is NOT a good solution -- concatenates \0!!!! Anyway, make a new "hack" buffer.
memcpy(hackhackhack,control->gtls_buffer_hack+length,control->gtls_buffer_hack_len);// Move what's left into the new one
hackhackhack=(char*)malloc(sizeof(char)*control->gtls_buffer_hack_len);// strndup is NOT a good solution -- concatenates \0!!!! Anyway, make a new "hack" buffer.
memcpy(hackhackhack,control->gtls_buffer_hack+length,control->gtls_buffer_hack_len);// Move what's left into the new one
free(control->gtls_buffer_hack);// Free the old one
control->gtls_buffer_hack=hackhackhack;// And make it the new one.
hackhackhack=NULL;
if(debug)printf("Quenched the thirst for data; new hack length is %i\n",control->gtls_buffer_hack_len);
if(debug)
printf("Quenched the thirst for data; new hack length is %i\n",control->gtls_buffer_hack_len);
returnlength;// hand it over.
}else{// length == hack length
memcpy(buffer,control->gtls_buffer_hack,length);// copy our buffer into theirs