17, May, 2018
Have you know that
a[-1]
is valid C? Of course, only if
*(a-1)
exists. So you may do something like:
int _a[N];
int *a = &(_a[N/2]);
for (int i = -N/2; i < N/2; ++i) {
a[i] = ...
}
But, why? One application I have encounterd is sprite engine for retro machine. It needs to render and handle collisions. Rendering is done by simple blitting memory. For collision testing I used AABB. It is represented by point (in center) and half size vector. This notation produces simpler and faster code than pattern with min/max points. But, now you need to shift your image coordinates by half of the extent in negative direction. No, more. With above pattern blitting with the same coordinates is possible.
19, Mar, 2018
Today, this line compiled well with gcc:
s_state_type_t *state = state;
It appeared during the cast from variable
void *_state;
.
16, Jan, 2018
The world got on hold. The new bug information spread around the globe. The fancy name “Meltdown” was even in the main media. The new bug can get access to the kernel data due to race condition in CPU itself. I must admit, it is interesting. At least from technical point of view. The hardware memory protection may be broken. It would not be a big problem - most computers are desktop stations, laptops. Of course, there may be more viruses, somebody may suffer from leak of important data. But, it is limited to single attacked machine. Really I still remember (and own) an Amiga. A computer without MMU in first place. It runs multitasked OS when every program can get access to every byte of memory. Even its IPC is based on this feature - send message with pointer to local memory. And it works quite robustly, no problem. The problem lies somewhere else. On server side of the world. It may hit those who handle running generic software on their computers. The clouds melt. Previous years were full of new cloud solutions. Every company wanted to shift their programs to services in the “cloud” (with subsription payment plan in background). And this is the problem. It was based on the faith that the virtualization may overcome malicous software. The first security precausion - use (ekhm and make) good software was shift to the side. And now it comes back. The centralization has always cost of a greater risk of failure.