Hehehometue wrote:Looks trippy...except I can still read the text. Also on closer inspection the image does have the text "Ghost", but in a ghost-like manner. Is the pun intended?


Hehehometue wrote:Looks trippy...except I can still read the text. Also on closer inspection the image does have the text "Ghost", but in a ghost-like manner. Is the pun intended?
Are you still not using warnings? Any decent compiler would warn you about using a pointer in place of an integer and vice versa. Also, traditionally only macro names consist of all capitals.mallard wrote:The cause? A missing variable name meant that what should have been "(var & MASK)" became "( & MASK)". That meant that a file was read into completely the wrong place in memory.
MASK is a constant, so is capitalised (it's C++, so constants really are constant.) The full code included casts e.g. "(char*)((uint32_t)var & MASK)", so with "var" missing, generated no warnings. The line is supposed to get the address of the start of the page that "var" (a pointer) points at.alexfru wrote:
Are you still not using warnings? Any decent compiler would warn you about using a pointer in place of an integer and vice versa. Also, traditionally only macro names consist of all capitals.
Ouch!mallard wrote:MASK is a constant, so is capitalised (it's C++, so constants really are constant.) The full code included casts e.g. "(char*)((uint32_t)var & MASK)", so with "var" missing, generated no warnings.
It would generate you an error if you used proper c++ casts instead of the c ones. Also constants in c++ are constants, not macros, and it's macros that are typically capitalised, not constants.mallard wrote:MASK is a constant, so is capitalised (it's C++, so constants really are constant.) The full code included casts e.g. "(char*)((uint32_t)var & MASK)", so with "var" missing, generated no warnings. The line is supposed to get the address of the start of the page that "var" (a pointer) points at.alexfru wrote:
Are you still not using warnings? Any decent compiler would warn you about using a pointer in place of an integer and vice versa. Also, traditionally only macro names consist of all capitals.
It seems there are more nitpickers in a semi-humours thread than there are in most of the code-related threads... I'm fully aware of the difference between a #define and a C++ constant. In C++ there is almost never a good reason to use a #define for a constant value (in C, "const" values can't be used at compile time (e.g. for array definitions) so they're a necessary evil there). There is at least one C++ style guide that advocates capitalising constants and it also makes sense if you have C and C++ mixed in a project (especially if the same name is used for a #define or a "const" depending on whether __cplusplus is defined...).Griwes wrote:
It would generate you an error if you used proper c++ casts instead of the c ones. Also constants in c++ are constants, not macros, and it's macros that are typically capitalised, not constants.
It looks like an underwater tunnel with a submarine inside.max wrote:something goes wrong
I said they are the same type. They are both void**.iansjack wrote:It's impossible to answer that without seeing the definition of the struct list. Is it also a void**?
It is returning void*, hence the cast.iansjack wrote:Why is your memory allocater returning a void** rather than a void*?
Yes, no other code is printing those two numbers.iansjack wrote:Are you sure that the line you have highlighted is the one printing the numbers?
Because list->elements is NULL. Later on in the function, you will see "if list->elements == NULL return NULL". The function calling this function is create_heap and if place_sorted_list returns NULL it generates the kernel panic.iansjack wrote:Why are you getting a kernel panic if the memory allocation didn't fail?
I did, and I couldn't figure it out. I can't do it now because I'm unexpectedly away from my computer for a week.iansjack wrote:And the most important question - why haven't you single-stepped the code in a debugger, when the answer to your confusion should be obvious?