PRE-2016 Valgrind: Still Reachable Leak detected by Valgrind

There is more than one way to define “memory leak”. In particular, there are two primary definitions of “memory leak” that are in common usage among programmers. The first commonly used definition of “memory leak” is, “Memory was allocated and was not subsequently freed before the program terminated.” However, many programmers (rightly) argue that certain … Read more

Should I cast the result of malloc (in C)?

No; you shouldn’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 bad. … Read more

How to get current process name in linux?

If you’re on using a glibc, then: #define _GNU_SOURCE #include <errno.h> extern char *program_invocation_name; extern char *program_invocation_short_name; See program_invocation_name(3) Under most Unices, __progname is also defined by the libc. The sole portable way is to use argv[0]

wait3 (waitpid alias) returns -1 with errno set to ECHILD when it should not

TLDR: you are currently relying on unspecified behaviour of signal(2); use sigaction (carefully) instead. Firstly, SIGCHLD is strange. From the manual page for sigaction; POSIX.1-1990 disallowed setting the action for SIGCHLD to SIG_IGN. POSIX.1-2001 allows this possibility, so that ignoring SIGCHLD can be used to prevent the creation of zombies (see wait(2)). Nevertheless, the historical … Read more

Should I use Helgrind or DRD for thread error detection?

While Helgrind can detect locking order violations, for most programs DRD needs less memory to perform its analysis. Also, DRD has support for detached threads. There are more subtle differences too – compare the respective manuals if you want to know more. See also http://valgrind.org/docs/manual/hg-manual.html and http://valgrind.org/docs/manual/drd-manual.html.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)