Vanilla.PDF  2.0.0
Cross-platform toolkit for creating and modifying PDF documents
Print buffer
error_type process_buffer(BufferHandle* buffer, int nested) {
string_type data = NULL;
char* local_string = NULL;
size_type size = 0;
size_type print_size = 0;
unsigned long long size_converted = 0;
print_spaces(nested);
print_text("Buffer begin\n");
RETURN_ERROR_IF_NOT_SUCCESS(Buffer_GetData(buffer, &data, &size));
if (size >= SIZE_MAX) {
unsigned long long size_long_long = size;
print_text("Buffer size is too big: %llu bytes\n", size_long_long);
return VANILLAPDF_TEST_ERROR_FAILURE;
}
print_size = size > 20 ? 10 : size;
size_converted = size;
local_string = (char*) calloc(sizeof(char), print_size + 1);
if (NULL == local_string) {
unsigned long long print_size_converted = print_size;
print_text("Could not allocate memory: %llu bytes\n", print_size_converted + 1);
return VANILLAPDF_TEST_ERROR_FAILURE;
}
memcpy(local_string, data, print_size);
print_spaces(nested + 1);
print_text("Size: %llu\n", size_converted);
print_spaces(nested + 1);
print_text("Data: %s\n", local_string);
free(local_string);
print_spaces(nested);
print_text("Buffer end\n");
return VANILLAPDF_TEST_ERROR_SUCCESS;
}