j
why doesmy code crash?
olli
why doesmy code crash?
Because you dereference a null pointer
j
where
j
?
olli
struct tm *tv = {0}; tv -> tm_mday = day; tv -> tm_mon= month-1; tv -> tm_year= year; dates[i++] = tv;
j
struct tm tv = {0}; tv.tm_mday = day; tv.tm_mon= month-1; tv.tm_year= year; dates[i++] = &tv;
olli
struct tm tv = {0}; tv.tm_mday = day; tv.tm_mon= month-1; tv.tm_year= year; dates[i++] = &tv;
Not better, the memory allocated inside the for loop is lost in the next iteration and the pointer invalidated
olli
You need to either define dates to be an array of structures (probably better solution) or need to allocate memory inside the door loop dynamically. In the later you need to make sure to free it in the end
j
i think i hava already done that
j
struct tm* dates[100];
j
@ollirz
olli
struct tm* dates[100];
But you are storing pointers here. Why not store the whole structure?
j
it kinda works
j
however in the struct is stored a completely different date thank what i was expecting
j
i was expecting as year 2012
j
and i got 3912
j
solved
j
i just did year-1900
j
ty
Ravi
Thanks for your welcome
Ravi
👍
Jay
Hi
olli
Hi
Ludovic 'Archivist'
Linux is so non POSIX the only way to read the size of free memory requires you to... Allocate
BinaryByter
Linux is so non POSIX the only way to read the size of free memory requires you to... Allocate
you allocate until you have allocated the max and then you look at how much you alocated?
BinaryByter
dafaq?
Ludovic 'Archivist'
Linux is so non POSIX the only way to read the size of free memory requires you to... Allocate
Thanks Linus for postponing addition of a relatively simple system call
BinaryByter
Hiii
BinaryByter
No we can't
BinaryByter
please read the rules of this caht
olli
Linux is so non POSIX the only way to read the size of free memory requires you to... Allocate
why? what result do you want to get? Does sysconf(_SC_PAGESIZE) * sysconf(_SC_AVPHYS_PAGES) not yield the desired result?
klimi
Mihail
Hi
Hmm
Mihail
What happened to your name?
Mihail
And profile picture?
klimi
I was sad
klimi
And now I'm I'll af
Mihail
And now I'm I'll af
So now you got time to code at least
Mihail
Finish your game
klimi
klimi
I'm in bed in pain....
Mihail
Oh
Mihail
Sad
klimi
Ye
Mihail
Wish you a fast recovery
klimi
Thanks
Shivam
Np
Dima
About Linux memory management... do they finally have a new syscall to get the real amount of ram usage instead of reading data from fd?
BinaryByter
JUST FUCKING TRY IT INSTEAD OF ASKING
Anonymous
guys
Anonymous
void func(char* string) { sprintf(string, "this is a test"); }
Anonymous
= *** stack smashing detected ***
Anonymous
char mystr[256]; func(&mystr);
Anonymous
never had this issue before
Anonymous
note: expected ‘char *’ but argument is of type ‘char (*)[256]’
Anonymous
wtf
Anonymous
ok fixed it
Anonymous
but srs
Anonymous
note: expected ‘char *’ but argument is of type ‘char (*)[256]’
Anonymous
what does gcc expect me to f*kin do
Anonymous
gfy gcc
Box of
gfy gcc
Try clang
Anonymous
aye clang never complains
Box of
Usually it gives more useful stuff
Anonymous
hey i want like a crc32 function
Anonymous
but i dont care about collisions
Anonymous
i just want really fast generation of obfusticated strings
Anonymous
which cant be unobfusticated
Anonymous
well they could be
Anonymous
but i dont care
Anonymous
its not important
Anonymous
input string as srand
Anonymous
duh
Box of
char mystr[256]; func(&mystr);
Have you tried removing &?
Anonymous
yeah