@Absinthe @alex Yes we have a discourse server. No sadly discourse doesnt federate however there has been talk about writing a plugin for it that does. Since it is the most likely service to federate int he future and the easiest one to hack to make it federate it is usually what we and other instances in the fediverse use.
Oh, yeah, on that line right above the free(ptr); second from the bottom... That is where you might want to do something with ptr :) Sorry, I meant to put that in there.
/* If you are going to use realloc, don't make this common mistake! */
#include <stdlib.h>
int main (void) {
size_t size = 16;
char * ptr = malloc(size);
size = 32;
/* This is wrong!
ptr = realloc(ptr, size);
ptr is allocated. If this call fails ptr will be set to NULL, and
the allocated memory will not be freed.
*/
char * tmp_ptr = realloc(ptr, size);
if (NULL != tmp_ptr) {
ptr = tmp_ptr;
} else {
/* This is the error case */
free(ptr);
ptr = NULL;
}
free(ptr);
}
Cute little trick for gcc or clang users: (run valgrind on it afterwards)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
void raii_char_free(char **);
#define raii_char_pointer char * __attribute__ ((__cleanup__(raii_char_free)))
void raii_char_free(char **p) {
free(*p);
}
int main (void) {
raii_char_pointer ptr = strdup("abcdefg");
printf("%s\n", ptr);
return 0;
}
use https://godbolt.org/ to test code on multiple compilers without having to have them installed locally
If you are programming in C consider adding c++ guards around your file scope variables and prototypes, and use the c++ compiler. You will find additional errors and warnings the c compilers alone won't find. Also, compile with both gcc and clang and use as many others as well as static analysis tools as you can. cppcheck can be your friend. valgrind can be your best friend.
On the Far Side of the Moon, China's Rover Discovers a Strangely-Colored Gel-Like Substance https://science.slashdot.org/story/19/09/01/2135222/on-the-far-side-of-the-moon-chinas-rover-discovers-a-strangely-colored-gel-like-substance?utm_source=rss1.0mainlinkanon&utm_medium=feed #moon
Scooters In Cities Are Becoming A Huge Problem https://tech.slashdot.org/story/19/09/01/2016237/scooters-in-cities-are-becoming-a-huge-problem?utm_source=rss1.0mainlinkanon&utm_medium=feed #transportation
Here's What Would Happen If You Tried to Storm Area 51 https://idle.slashdot.org/story/19/09/01/056201/heres-what-would-happen-if-you-tried-to-storm-area-51?utm_source=rss1.0mainlinkanon&utm_medium=feed #military
Should We Be Allowed To Kick Robots? https://hardware.slashdot.org/story/19/09/01/0424244/should-we-be-allowed-to-kick-robots?utm_source=rss1.0mainlinkanon&utm_medium=feed #robot
The green faerie