Message from C, C++ talks

July 2019

— You can check before access to memory

— Bad variant

— Instead of checking before every access, I can check one time after malloc

— Allocation may be only 1 time, and use it 10 time... so 1 check vs 10 checks


Allocate big big buffer, try to write with system call write at last address and now you have all memory

— Otherwise enter in sleep and wait to purchase other Memory 😂

— But for real, are you see such cases in real life?

— When malloc return 0

— In real case many people check if address is valid

— I check each pointer before use(if it passed to me trow params)

— Put checking pointer after allocation...

— More checks = better code

— Okay, for example, malloc returned 0.. i see it.. and so what? exit(-1) ?)

— Not always

— Better check before function, inside function, and in the start despite of not checking at all