this is my first time using dynamic memory allocation and I don't know how to check for memory leaks in my code
Just in general, how can I check for memory leaks in visual studio? I don't know how to track the heap and stack and so I'm mostly shooting in the dark here.
I should mention I used windows 10 and from what I know Valgrind doesn't offer support to W10
Dictionary* createDic(Dictionary* dics, int* size) {
Dictionary* temp = NULL;
//some extra code for the variables below which arent al that important for the question
temp = malloc(++*size * sizeof(Dictionary));
if (temp==NULL)
{
printf("\nThe creation of the dictionary has failed!");
*size+=-1;
freeArray(splitReciever,count);
return dics;
}
for (int i = 0; i < (*size - 1); i++)
{
temp[i] = dics[i];
}
temp[*size - 1].languages = splitReciever;
temp[*size - 1].numOfLanguages = count;
temp[*size - 1].wordList = NULL;
dics = temp;
return dics;
}
I was also wondering if this code would work, again, without causing memory leaks?
Dictionary* createDic(Dictionary* dics, int* size) {
Dictionary* temp = NULL;
//some extra code for the variables below which arent al that important for the question
temp = realloc(dics , ++*size * sizeof(Dictionary));
if (temp==NULL)
{
printf("\nThe creation of the dictionary has failed!");
*size+=-1;
freeArray(splitReciever,count);
return dics;
}
temp[*size - 1].languages = splitReciever;
temp[*size - 1].numOfLanguages = count;
temp[*size - 1].wordList = NULL;
dics = temp;
return dics;
}