Skip to content

Commit

Permalink
resolves #11 (#13)
Browse files Browse the repository at this point in the history
* increase height of preview canvas image in demo

* small sized curves get cutoff (e.g. 3x3) because the window scaling
  factor is only 1.1 and the margins are significant at small scales.
  Increasing the height factor to 2 (from 1.1) alleviates the problem
  while minimizing the risk of the canvas spilling over horizontally.

* resolves #11

* vestigial test code that caused `gilbert_d2xy(&x, &y, 7861, 490, 490)` to incorrectly return
  -1 (there was a `max_iter` check to return after some hard coded value)
* added test to make sure at least that condition is tested for
* `gilbert.c` had buffer overrun setting last byte of `buf`, correctly sets `buf[1023]='\0'`
  instead of `buf[1024]`
  • Loading branch information
abetusk authored Jun 9, 2024
1 parent 75133be commit a293ab7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 1 addition & 6 deletions ports/gilbert.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,13 @@ int gilbert_d2xy_r(int dst_idx, int cur_idx,
int *xres, int *yres,
int ax,int ay,
int bx,int by ) {
static int max_iter = 0;

int nxt_idx;
int w, h, x, y,
dax, day,
dbx, dby,
di;
int ax2, ay2, bx2, by2, w2, h2;

if (max_iter > 100000) { return -1; }
max_iter++;

w = abs(ax + ay);
h = abs(bx + by);

Expand Down Expand Up @@ -891,7 +886,7 @@ int main(int argc, char **argv) {
}

strncpy(buf, argv[1], 1023);
buf[1024]='\0';
buf[1023]='\0';

w = atoi(argv[2]);
h = atoi(argv[3]);
Expand Down
3 changes: 3 additions & 0 deletions tests/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,6 @@ gilbert_cmp2 $x $y
x=7 ; y=6 ; z=4
gilbert_cmp3 $x $y $z

x=490 ; y=490
gilbert_cmp2 $x $y

0 comments on commit a293ab7

Please sign in to comment.