in inc/c_util/two_d_array_ll.h [177:223]
int TWO_D_ARRAY_LL_ALLOCATE_NEW_ROW(C)(TWO_D_ARRAY_LL(T) two_d_array, uint32_t row_index) \
{ \
int result; \
/* Codes_SRS_TWO_D_ARRAY_07_014: [ If two_d_array is NULL, TWO_D_ARRAY_ALLOCATE_NEW_ROW(T) shall fail and return a non-zero value. ]*/ \
if (two_d_array == NULL) \
{ \
LogError("Invalid arguments: TWO_D_ARRAY (" MU_TOSTRING(T) ") two_d_array=%p", two_d_array); \
result = MU_FAILURE; \
} \
else \
{ \
/* Codes_SRS_TWO_D_ARRAY_07_015: [ If row_index is equal or greater than row_size, TWO_D_ARRAY_ALLOCATE_NEW_ROW(T) shall fail and return a non-zero value. ]*/ \
if (row_index >= two_d_array->rows) \
{ \
LogError("Invalid arguments: uint32_t row_index=%" PRIu32 " out of bound, total_rows=%" PRIu32, row_index, two_d_array->rows); \
result = MU_FAILURE; \
} \
else \
{ \
if (two_d_array->row_arrays[row_index] != NULL) \
{ \
/* Codes_SRS_TWO_D_ARRAY_07_016: [ If the row specified by row_index has already been allocated, TWO_D_ARRAY_ALLOCATE_NEW_ROW(T) shall fail and return a non-zero value. ]*/ \
result = MU_FAILURE; \
LogError("Invalid arguments: uint32_t row_index=%" PRIu32 " has already been allocated", row_index); \
} \
else \
{ \
/* Codes_SRS_TWO_D_ARRAY_07_017: [ Otherwise, TWO_D_ARRAY_ALLOCATE_NEW_ROW(T) shall allocate memory for the new row and return zero on success. ]*/ \
T* new_row = malloc_2(two_d_array->cols, sizeof(T)); \
if (new_row == NULL) \
{ \
/* Codes_SRS_TWO_D_ARRAY_07_018: [ If there are any errors then TWO_D_ARRAY_ALLOCATE_NEW_ROW(T) shall fail and return a non-zero value. ]*/ \
LogError("failure in malloc_2(number of cols=%" PRIu32 ", sizeof(" MU_TOSTRING(T) ")=%zu)", \
two_d_array->cols, sizeof(T)); \
result = MU_FAILURE; \
} \
else \
{ \
TWO_D_ARRAY_TYPEDEF_NAME(T)* array = THANDLE_GET_T(TWO_D_ARRAY_TYPEDEF_NAME(C))(two_d_array); \
array->row_arrays[row_index] = new_row; \
result = 0; \
} \
} \
} \
} \
return result; \
}