Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved allocation of plane cells #2764

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

mulle-nat
Copy link
Contributor

  • size_t overflow check for cell array
  • use calloc to gain mucho speed for huge dimensions

* use calloc to gain mucho speed for huge dimensions
@mulle-nat
Copy link
Contributor Author

mulle-nat commented Feb 28, 2024

Your last commit IMO has an error, in that it now doesn't check for cols == 0 || rows == 0 anymore, which it used to do. This is also done by my patch.

I tested it with this test code:

  for( unsigned int y = (unsigned int) -1; y != 2; y++)
    for( unsigned int x = (unsigned int) -1; x != 2; x++)
    {
      ncplane_options nopts = {
       .y = 0,
       .x = 0,
       .rows = y,
       .cols = x,
       .flags = 0
      };

      struct ncplane* test = ncplane_create(n, &nopts);
      if( test != NULL)
      {
        if( x != 1 && y != 1)
            abort();
        ncplane_destroy( test);
      }
    }

@dankamongmen
Copy link
Owner

Your last commit IMO has an error, in that it now doesn't check for cols == 0 || rows == 0 anymore, which it used to do.

wow, it sure does, doesn't it? embarrassing! thanks a lot for the catch.

Copy link
Owner

@dankamongmen dankamongmen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your fix for the zero check is obviously correct and necessary. i find the rest questionable.

src/lib/notcurses.c Show resolved Hide resolved
src/lib/notcurses.c Show resolved Hide resolved
src/lib/notcurses.c Show resolved Hide resolved
@dankamongmen dankamongmen merged commit 2e2cc81 into dankamongmen:master Mar 1, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants