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

[RDY] GA_APPEND() and GA_APPEND_VIA_PTR() #830

Closed
wants to merge 3 commits into from

Commits on Jun 26, 2014

  1. ga_growsize should be >= 1

    I know it could be 0 sometimes. Running the tests with
    `assert(gap->ga_growsize > 0)` in ga_grow() crashes nvim while running the
    tests.
    
     - Add a setter for ga_growsize that checks whether the value passed is >=1 (log
    	 in case it's not)
     - log when ga_grow() tries to use a ga_growsize that's not >=1
     - use GA_EMPTY_INIT_VALUE is many places
    felipecrv committed Jun 26, 2014
    Copy the full SHA
    c93fb0c View commit details
    Browse the repository at this point in the history
  2. Introduce GA_APPEND()

    This macro is used to append an element to a growable array. It replaces this
    common idiom:
    
       ga_grow(&ga, 1);
       ((item_type *)ga.ga_data)[ga.ga_len] = item;
       ++ga.ga_len;
    felipecrv committed Jun 26, 2014
    Copy the full SHA
    f664632 View commit details
    Browse the repository at this point in the history
  3. Introduce ga_append_via_ptr() and GA_APPEND_VIA_PTR()

    Similar to GA_APPEND(). Replaces this pattern:
    
        ga_grow(&ga, 1);
        item_type *p = ((item_type *)ga.ga_data) + ga.ga_len;
        p->field1 = v1;
        p->field2 = v2;
        ga.ga_len++;
    felipecrv committed Jun 26, 2014
    Copy the full SHA
    3a2b8f7 View commit details
    Browse the repository at this point in the history