Questions tagged [free]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
2answers
42 views

Speller program runs accurately with memory leaks. When I add free() to correct memory leak, program stops executing

My speller program runs and produces accurate outputs. It passes all but one of the check50 checks. It fails because it has a memory leak. I added free() to the load loop where I am allocating ...
0
votes
1answer
30 views

Speller - not sure what's wrong

I'm struggling trying to find what the error is or why speller is behaving the way it is. Currently, when I run help50 valgrind, I get this error message: ==8634== 56 bytes in 1 blocks are definitely ...
0
votes
1answer
29 views

pset4 speller trie segmentation fault

I am doing the trie version of speller in pset4 and keep getting a segmentation fault. I have run my code on short dictionaries and short text files and it seems to work just fine but when I try ...
0
votes
1answer
159 views

Unload works on small dictionary, but not on large? (speller.c / hash table method)

When testing with the small dictionary, it unloads as expected however when testing with the large dictionary, I receive the error "Could not unload dictionaries/large." The only difference that I've ...
0
votes
1answer
67 views

pset5 (trie) valgrind memory leak

I'm having trouble with the last step of pset5, valgrind. When I run it with the test text I get: Looks like you're trying to access 8 bytes of memory that isn't yours? Did you try to index into an ...
0
votes
1answer
180 views

PSET4: free(): invalid next size (fast)

So as the title says, I'm trying to do the pset4 where I get this error when I try to execute the program. I've searched the forum and also Reddit, and I understood that I've some issue with the ...
0
votes
1answer
63 views

Pset5 Unload Giving Double Free or Corruption error

My title pretty much explains the problem. I can tell that the problem probably exists where I called free (marked in my code). Here's the code below: bool unload(void) { node* trav = head; ...
0
votes
1answer
31 views

How/when to free this memory? (pset6/server)

Here is my implementation of the indexes function in pset6: char* indexes(const char* path) { char* php = "index.php"; char* html = "index.html"; char* pathCopy = malloc(strlen(path) + ...
0
votes
1answer
49 views

check50 fails on caesar.c when using free()

I have a little problem. I can get get this to pass all the checks, but only if I remove the free() statement on L71 Link to code removed by andy5995 If I leave the free() statement in, this is ...
0
votes
1answer
66 views

Pset6 - CS50. Segmentation fault for free(index)

For pset6, implementing a server, almost everything works except the indexing function. I get a segmentation error after the use of this function when trying to free(index). This is the returned ...
0
votes
1answer
537 views

per valgrind: multiple invalid read and invalid write; invalid free(); “still reachable: 568 bytes in 1 blocks”

My recover.c seems to recover all images correctly (per check50) but still seems to have issues with a couple of things per valgrind (output copied at the bottom). As background, I am using a ...
0
votes
1answer
84 views

Pset6 Indexes free() invalid next size error

I'm getting this error when I try to run my server. I don't what's been causing it. char* indexes(const char* path) { char* path_php = malloc(sizeof(char) * strlen(path)); char* path_html = ...
0
votes
1answer
6k views

Invalid pointer error when using free()

I was trying to practice malloc'ing and freeing memory, however when I run the free() function in this program an error is returned for an invalid pointer. Can anyone tell me what I'm doing wrong? ...
0
votes
1answer
75 views

pset5 root node not freed

It looks like my unload function is not working properly. Valgrind shows 0 errors, but when I print out the address of my root node, it is not NULL. Hence my unload function (which returns true if ...
0
votes
3answers
299 views

Is vmware free or chargeable?

I am studying CS50 through edx.org In order to solve pset1, I have to download vmware workstation. However, the software is not free and the website is requesting me to pay 200 USD. Is vmware free ...
1
vote
1answer
36 views

spellchecker unload not freeing 1 block

What is not freeing!? [code snipped by mod] // end of load function (mod comment) return true; fclose(dict_file); } [code snipped by mod]
0
votes
1answer
572 views

pset 05 trie large dictionary unload issue

I am working through pset5 (Mispellings) using a trie and I am stumped. This is the error exactly from gdb (sample is a text file I made and works just fine with the small dictionary): Starting ...
0
votes
1answer
168 views

Trie Spellchecker unload() - two allocs not freeing

My freeNode() function goes through each child of my root node and free()'s each of them from the bottom back up to the root. Two of the allocs are not being free()'d. #include <stdbool.h> #...
0
votes
2answers
478 views

Why can't I call the function “free” to release memory!

Help! I am using malloc to create an array on the heap... but I can't seem to get the compiler to recognize the call to "free"! /******************************************** * Program Name: ...
1
vote
0answers
2k views

Valgrind says “Invalid read of size 4” while freeing memory recursively in a trie

My PSET "mispelling" works fine and contains no memory leak but when I run the program with Valgrind it says Invalid read of size 4. My unload function calls a deleteTrie function which looks like ...
0
votes
2answers
361 views

pset6-unload free() : invalid pointer

i get everything working but the unload function, there seems to be something wrong with free() here' the code: void freeChild(node* curr) { if(curr == NULL) return; for(int i = 0; i &...
1
vote
1answer
178 views

segfault while freeing memory in speller

I'm having an enormous problem implementing the unload function for the speller in pset6. Although it's not a well-polished algorithm I first wanted to make a quick design that allows me to take a ...
0
votes
1answer
56 views

valgrind free and leaks

In the continued lecture of week 5, it is stated that if we don't free memory in our programs, this can lead to a memory leak. But, just to be clear, when my program exit, all the memory used by my ...
3
votes
1answer
12k views

How to free a nested struct?

In preparation for my final project, I am writing a C program that handles task lists. It utilizes a nested struct. For every line it reads from a file it creates a struct of type task. Each task then ...
2
votes
1answer
125 views

Should We Free Memory Allocated By GetString()?

Running valgrind with line 42 commented out shows that there are indeed some leaks. If we DON'T comment out line 42, then there are no leaks. Here is the code // copy-1.mp4 from Week4 Walkthroughs //...