Question: Having trouble with this error:Code 1 3 : Valgrind Detected Errors # + END _ SRC * * LINE DIFFERENCES from file 'test - results
Having trouble with this error:Code : Valgrind Detected Errors
#ENDSRC
LINE DIFFERENCES
from file 'testresultsrawprobdifflines.tmp
#BEGINSRC text
If this section is empty, there are no line differences
ACTUAL: Return Code : Valgrind Detected Errors
#ENDSRC
VALGRIND LOG from: testresultsrawprobvalgrd.tmp
Memcheck, a memory error detector
Copyright C and GNU GPLd by Julian Seward et al
Using Valgrind and LibVEX; rerun with h for copyright info
Command: testbakefuncs bakeaddimplicitrules
Parent PID:
HEAP SUMMARY:
in use at exit: bytes in blocks
total heap usage: allocs, frees, bytes allocated
bytes in blocks are definitely lost in loss record of
at xCB: malloc vgreplacemalloc.c:
by xCB: strdup in usrliblibcso
by x: bakeaddimplicitrules bakefuncs.c:
by xF: main testbakefuncsc:
LEAK SUMMARY:
definitely lost: bytes in blocks
indirectly lost: bytes in blocks
possibly lost: bytes in blocks
still reachable: bytes in blocks
suppressed: bytes in blocks
For lists of detected and suppressed errors, rerun with: s
ERROR SUMMARY: errors from contexts suppressed: from
Need to fix this code:
rulet bakeaddemptyrulebaket bake
Check if the rule array needs to be resized
if bakerulecount bakerulecapacity
Double the capacity of the rule array
sizet newcapacity bakerulecapacity ;
rulet newrules reallocbakerules, newcapacity sizeofrulet;
if newrules NULL
perrorError: memory reallocation failed";
return NULL;
Update bake structure with the new rule array and capacity
bakerules newrules;
bakerulecapacity newcapacity;
Get a pointer to the next available rule slot
rulet newrule &bakerulesbakerulecount;
Increment the rule count before potential reallocation
bakerulecount;
Initialize the new rule with memset
memsetnewrule, sizeofrulet;
Return a pointer to the new empty rule
return newrule;
done
int bakeaddimplicitrulesbaket bake
Iterate over all rules appending implicit rules for any
dependency that is not an explicit target.
for int i ; i bakerulecount; i
rulet rule &bakerulesi;
for int j ; ruledepsj NULL; j
char dependency ruledepsj;
Check if the dependency is an explicit target
int found ;
for int k ; k bakerulecount; k
if strcmpbakerulesktarget, dependency
found ;
break;
If the dependency is not an explicit target, add an implicit rule
if found
Allocate memory for the implicit rule target
char implicittarget strdupdependency;
if implicittarget NULL
perrorError: memory allocation failed";
return ;
Add the implicit rule to the bake structure
rulet implicitrule bakeaddemptyrulebake;
if implicitrule NULL
freeimplicittarget; Free memory in case of failure
return ;
Initialize the implicit rule
implicitruletarget implicittarget;
implicitruledeps NULL; Mark the end of dependencies
SETBITimplicitruleruleflags, RULEIMPLICITBIT;
implicitrulecmdcount ;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
