[PATCH 1/2] Print: fix issues when printing a lot of dives in table print

Dirk Hohndel dirk at hohndel.org
Fri Dec 6 09:34:57 UTC 2013


On Fri, 2013-12-06 at 18:24 +0200, Lubomir I. Ivanov wrote:
> From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
> +	/* the algorithm bellow processes the table rows in multiple passes,
> +	 * compensating for loss of space due to moving rows on a new page instead
> +	 * of truncating them.
> +	 * there is a 'passes' array defining how much percents of the total
> +	 * progress each will take. given, the first and last stage of this function
> +	 * use 10% each, then the sum of passes[] here should be 80%.
> +	 * two should be enough! */
> +	const int passes[] = { 70, 10 };
> +	int tableHeight = 0, lastAccIndex = 0, rowH, accH, headings;
> +	bool isHeading = false;
> +
> +	for (int pass = 0; pass < sizeof(passes); pass++) {

http://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html#The-sizeof-Operator

"You can use the sizeof operator to obtain the size (in bytes) of the
data type of its operand."

So no, sizeof(passes) does not give you the number of elements in the
array.

sizeof(passes) / sizeof(passes[0]) does...

Oops (actually: SIGSEGV)

/D



More information about the subsurface mailing list