« first day (3048 days earlier)      last day (1976 days later) » 

3:34 AM
@Almo That's great, it reminded me of Myst.
 
 
5 hours later…
8:14 AM
@Pikalek return statements
 
8:25 AM
glfw seems to be using 0s and 1s
I might be switching to int, just like the cool kids
 
 
6 hours later…
2:17 PM
0
Q: How do I swap the buffers when using a Win32 window with Vulkan?

Gabriele ViertiI was recently told here how to manage the integration between Vulkan and Win32. I am writing a windowing library like "GLFW", that is only going to support Vulkan; I have now come to the point where I need to implement SwapBuffers(Window) type of function; I have tried to reverse engineer Glfw'...

Do you guys have any idea on how I could do this?
 
 
3 hours later…
4:59 PM
@Almo ooh cool title
 
5:21 PM
I might be having huge memory leaks
c++ looks very appealing to me at the moment :D
screw it, I'm going for c++
 
5:47 PM
or maybe not, who knows
 
6:11 PM
the thing is that it's talking about Visual C++ stuff
 
user92578
6:24 PM
Most likely just sanity checks from the runtime
 
user92578
That is not necessarily a memory leak, could also just be bad access
 
I can't figure out where it's coming from though
i tried profiling but everytime it breaks on a different line of code
here is the problem:
i compile the program, and run it; I do the same thing for 5 times and on the 6th attempt, the window takes a long time to close (or the whole thing crashes like that ^)
 
user92578
Well that actually does sound like a memory leak, or memory corruption
 
user92578
Tough to say without seeing code
 
 
1 hour later…
7:56 PM
oh wait
could it be the fact that i am not setting the window pointer to NULL after freeing the memory with free()?
nope, that's not it
 
8:46 PM
it seems that my code is corrupting the heap
fixed :D
I was malloc-ing like this:
Window* win = (Window*)malloc(sizeof(Window*))
instead of Window* win = (Window*)malloc(sizeof(Window))
kinda stupid, but hey i got to an end!
 
nwp
9:33 PM
@GabrieleVierti Why are you casting malloc?
 
@GabrieleVierti yeah, that's what I meant. In C when evaluating to a T/F state, zero is false, anything else is true (i.e. if it's not zero /false, the only other option is for it to be true). It's nice for errors as 0 means false (no error) & an int value can simultaneously mean both true (had an error) and be used as a look up as to the specific type of error.
 
@nwp yeah, that doesn't make much sense
 
Of course the drawbacks are a lack of type safety & the related temptation to do 'clever' things, like error code arithmetic.
 
1995
A: Do I cast the result of malloc?

unwindNo; you don't cast the result, since: It is unnecessary, as void * is automatically and safely promoted to any other pointer type in this case. It adds clutter to the code, casts are not very easy to read (especially if the pointer type is long). It makes you repeat yourself, which is generally...

never doing it again :O
One thing i don't really understand that well is why libraries often use hex for error codes
i mean, do you really plan on handling such a huge amount of error codes that you can't use integers?
 
nwp
Hexadecimal is a number representation, not a data type.
 
9:42 PM
yeah, but why would you write 0x200 instead of 512?
 
nwp
I don't know. It's easier to see individual bytes that way, but that doesn't matter for error codes. I guess it's just preference.
 
gotcha
coming back to the problem i had before, an aswer on SO even specifies "you won't get a compiler error, but a compiler warning. casting the result of malloc without including <stdint.h> can cause lots of trouble like runtime errors"
I gotta be honest with you, I'm kind of scared of casting stuff in c now..
 
nwp
You should be. Casts are bad. And if you use C++ completely avoidable. Until you use C libraries.
 
10:09 PM
Yes, casting in C will allow you to do some things that you probably don't mean & generally shouldn't do. I've always seen the motto of C as "well, you're the programmer, so if you say so, sure, I'll do that...". You want to treat an int as if it were an array of ints? Well, that would allow you to access memory that doesn't belong to the int, but if you really want to, okay, here you go.... [seg fault].
 
nwp
And then you have optimizing compilers that say "lol UB, gonna remove all your code".
 

« first day (3048 days earlier)      last day (1976 days later) »