LOL. I blame the compiler anyway for giving me the wrong error message ;)
Type: Posts; User: TalonStriker
LOL. I blame the compiler anyway for giving me the wrong error message ;)
list.c:35: error: void value not ignored as it ought to be
This is the code:
Table *create(void)
{
return NULL;
}
edit: I found the bug!!!!!!!
Turns out that it had nothing to do with overwriting memory at all.
In this code in delete()
/* update the capacity of the table */
if...
but this is precisely the sort of thing that mcheck is supposed to prevent right? If you do overrun, mcheck will start complaining. Or does mcheck only complain when you overwrite the...
As far as I'm concerned I really don't care if valgrind catches it or not...what matters is whether the mcheck functions catch it since thats the only way the professor can check my code for memory...
I understand what you're saying (I'll implement it in a sec) but I don't understand how this corrupts the heap. If I am indeed overwriting something because I'm going 16 bytes past where I want to,...
GET_RELATIVE_MEM_ADDR_OF_INDEX is something I defined.
#define GET_RELATIVE_MEM_ADDR_OF_INDEX(y) ((y)*sizeof(Item))
yeah the macro name is itself bigger than the code it represents but i didn't...
yes i changed that but it still doesnt work.well this is actually a project for my class. The professor provided us with the tests (which we shouldn't modify) that use the mcheck funcs. So i have...
the valgrind info:
Reserving 301445280 to 301445728
Alloced table at 301445216
Adding 1, 100 to 301445280
new items at 0
Size: 0
==733== Invalid write of size 8
==733== at 0x4009E6:...
Well yeah I've fired my debugger and looked at what heap->items is pointing to...so far I haven't caught anything fishy
If you have the patience to look over the code, here it is (at least the...
I don't think max has anything to do with it because I'm not using it to base my calculations of the heap size.
What entails heap corruption? I know that if you write past the end of allocated...
For some reason valgrind is giving me a out of memory error... [:?]
Firstly, here's the output of my program:
Heres the code at causes the mem leak:
printf("table at %d\n",...
actually, nevermind. I foud the bug... The valgrind error info was pointing at the spot where I allocated memory--ot where the leak occured.
Well it's called from the first line of get_trailer(char *), and I'm passing the results of this code into get_trailer()
sscanf(command_string, "%s %s", command, arg1); //command_string is...
I'm using this implementation of strdup. When I was checking whether I had any memory leaks, the compiler claims that there is a memory leak at line 4 of the function.
1179 char *dup =...
I think I'll continue using the size of version, it makes more sense to me that way... I just wanted to make sure that the first version wasn't wrong
oh yeah...thanks for pointing that out.
I'm confused, I changed 1077 to
*(temp + (b-a+1) * sizeof(char)) = '\0'; /* add a NUL at the end */ and its still being skipped
Look at this piece of code:
1071 {
1072 b = strchr(a, '\0');
1073 finished = 1;
1074 }
1075
1076 ...
I see that strdup isn't on the list :(
Heh, I learned more out of this ordeal that I bargained for.
Actually, I didn't quite understand what "standard" meant in this context. From your explanation, for a function to be standard, its prototype should exist in the same library in all compilers....or...
Ah... I see... suppose I hadn't used -Werror, it would have created the object code...but would that object code be "wrong" (i.e. not run properly after linking)?
Well I'm using the gcc compiler.
Thanks. I'm not sure why strdup() not being in standard C effects anything. According to the gcc API, strdup is supported in gcc. However, I'm compiling with...
Hi guys,
When I compile this code, I'm getting the following error:
warning: implicit declaration of function 'strdup'
I've included <string.h> and <wchar.h> so I shouldn't be getting the...