Why doesn’t C++ make the structure tighter?

Class and struct members are required by the standard to be stored in memory in the same order in which they are declared. So in your example, it wouldn’t be possible for d to appear before b. Also, most architectures prefer that multi-byte types are aligned on 4- or 8-byte boundaries. So all the compiler … Read more

Why does git keep telling me it’s “Auto packing the repository in background for optimum performance”?

I found the solution from the second comment you provided, Trengot, thanks. It turns out that I had some dangling blobs, which were in .git/objects/17 and hence triggering the packing: $ git fsck dangling blob d9ff0aeac4aa8b4e0907daed675ebf60278bc977 dangling blob dbff2d073741f9775c815d4a3c623736af224dad dangling blob e1ffbab1c5b985cd1cd3bc0281075ea2ed80744a dangling blob fdff59878ccb3a75689f4acca615cfb635288774 This cleaned them up: $ git gc –prune=now Be aware, … Read more

Structure padding and packing

Padding aligns structure members to “natural” address boundaries – say, int members would have offsets, which are mod(4) == 0 on 32-bit platform. Padding is on by default. It inserts the following “gaps” into your first structure: struct mystruct_A { char a; char gap_0[3]; /* inserted by compiler: for alignment of b */ int b; … Read more

What algorithm can be used for packing rectangles of different sizes into the smallest rectangle possible in a fairly optimal way?

See this page on the ARC project for a survey of solutions, there is a trade-off between implementation complexity/time and optimality, but there is a wide range of algorithms to choose from. Here’s an extract of the algorithms: First-Fit Decreasing Height (FFDH) algorithm FFDH packs the next item R (in non-increasing height) on the first … Read more

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