-
Notifications
You must be signed in to change notification settings - Fork 0
void sample_function(int** input1)
This page describes the stub code for function `void sample_function(int** input1), a method whose argument is double pointer.
The argument with pointers can be input, output and both.
Usually, the argument of a double pointer is the output.
It rarely is an input.
An output pattern is described on this page.
The stub codes in source file is like below.
long sample_function_called_count;
int* sample_function_input[STUB_BUFFER_SIZE_1];
int sample_function_input_return_value[STUB_BUFFER_SIZE_1][STUB_BUFFER_SIZE_2];
long sample_function_input_return_value_size[STUB_BUFFER_SIZE_1];
void sample_function_init()
{
sample_function_called_count = 0;
for (int index = 0; index < STUB_BUFFER_SIZE_1; index++) {
sample_function_input[index] = 0;
for (int index2 = 0; index2 < STUB_BUFFER_SIZE_2; index2++) {
sample_function_input_return_value[index][index2] = 0;
}
sample_function_input_return_value_size[index] = 0;
}
}
void sample_function(int** input1)
{
sample_function_input[sample_function_called_count] = input;
for (int index = 0;
index < sample_function_input_value_size[sample_function_called_count];
index++)
{
*(input1 + index) = &sample_function_input_return_value[sample_function_called_count][index];
}
sample_function_called_count++;
}
The variable sample_function_input_return_value[STUB_BUFFER_SIZE_1][STUB_BUFFER_SIZE_2]
is a buffer to store the values of the area to be set in the double pointer.
The buffer is defined as two-dimensional array to hold the value of the argument for each execution.
The naming rule of the buffer is below:
(argument data type without pointer) (function name)_(argument name)_return_value[STUB_BUFFER_SIZE_1][STUB_BUFFER_SIZE_2];
The variable sample_function_input_return_value_size[STUB_BUFFER_SIZE_1]
holds the size to set to the area.
The naming rule of the buffer is below:
long (function name)_(argument name)_return_value_size[STUB_BUFFER_SIZE_1]
The variable is defines as an array to be called multiple calls. The macro STUB_BUFFER_SIZE_1
to show the size of array is defined in its header file and the default size is 100.