Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
38 user(s) are online (24 user(s) are browsing Forums)

Members: 0
Guests: 38

more...

Support us!

Headlines

Report message:*
 

Re: Memory protection and tasks/processes

Subject: Re: Memory protection and tasks/processes
by LiveForIt on 2021/3/1 20:15:52

@afxgroup

Quote:

if (pointer)
free(pointer)


this should be

Quote:

if (pointer)
free(pointer)
pointer = NULL;


if do not set pointer to NULL then “if (pointer)” is useless.

I see lots of init code, exit at first failure, and so do not set other pointers later in functions, so you have none initialized pointers, it’s extremely typical.

Some tools to find bugs, will actually suggest you should remove “if (pointer)”, because 99% of time does not crash the OS and program, only 1% of time it takes down the OS, but it considered a bug because slows down the program, crazy, I guess Linux people do not care anymore, because the OS can handle almost anything.


Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project