I have this function which is using calloc to create an array of structure proposition. Whenever I try to free the resulting array from another fuction, it crashes.
proposition* get_matching_propositions(char *pcde, proposition *propositions, int *match_count)
{    
    proposition *matches;
    int         count       = get_count_from_stream(ptf_proposition, sizeof(proposition)),
                cptr_match  = 0;
    for (int i = 0; i < count; i++)
    {
        if (strcmp(propositions[i].cde, pcde) == NULL)
        {
            cptr_match++;
        }
    }
    matches = (proposition*) calloc (cptr_match, sizeof(propositions));
    assert(matches != NULL);
    cptr_match = 0;
    for (int i = 0; i < count; i++)
    {
        if (strcmp(propositions[i].cde, pcde) == NULL)
        {
            matches[cptr_match] = propositions[i];
            cptr_match++;
        }
    }
    *match_count = cptr_match;
    return matches;
}
Inside some other function I have:
proposition *matches =
    get_matching_propositions(current_question.cde, propositions, &match_count);
free(matches);
Then the program crashes with this message :
Process returned -1073740940 (0xC0000374)   execution time : 1.370 s.
 
    