HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //home/ubuntu/neovim/src/nvim/garray.h
#pragma once

#include <stdbool.h>
#include <stddef.h>

#include "nvim/garray_defs.h"  // IWYU pragma: keep
#include "nvim/memory.h"

#define GA_EMPTY(ga_ptr) ((ga_ptr)->ga_len <= 0)

#define GA_APPEND(item_type, gap, item) \
  do { \
    ga_grow(gap, 1); \
    ((item_type *)(gap)->ga_data)[(gap)->ga_len] = (item); \
    (gap)->ga_len++; \
  } while (0)

#define GA_APPEND_VIA_PTR(item_type, gap) \
  ga_append_via_ptr(gap, sizeof(item_type))

#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "garray.h.generated.h"
#endif

/// Deep free a garray of specific type using a custom free function.
/// Items in the array as well as the array itself are freed.
///
/// @param gap the garray to be freed
/// @param item_type type of the item in the garray
/// @param free_item_fn free function that takes (item_type *) as parameter
#define GA_DEEP_CLEAR(gap, item_type, free_item_fn) \
  do { \
    garray_T *_gap = (gap); \
    if (_gap->ga_data != NULL) { \
      for (int i = 0; i < _gap->ga_len; i++) { \
        item_type *_item = &(((item_type *)_gap->ga_data)[i]); \
        free_item_fn(_item); \
      } \
    } \
    ga_clear(_gap); \
  } while (false)

#define FREE_PTR_PTR(ptr) xfree(*(ptr))

/// Call `free` for every pointer stored in the garray and then frees the
/// garray.
///
/// @param gap the garray to be freed
#define GA_DEEP_CLEAR_PTR(gap) GA_DEEP_CLEAR(gap, void *, FREE_PTR_PTR)