So, I was reading the source code of libsystemd and found this line that I think can only be some kind of obscure trickery.
Please can someone explain.
This is the line, so you don't have to open the link to read it.
device = new(sd_device, 1);
Where device
is declared right before, as sd_device *device;
And sd_device
is a type.
new
is a macro where the type sd_device
in device = new(sd_device, 1);
is used as sizeof(sd_device)
:
#define new(t, n) ((t*) malloc_multiply(n, sizeof(t)))
After preprocessing, the line in question therefore becomes a call to malloc_multiply
:
device = ((sd_device*) malloc_multiply(1, sizeof(sd_device)));