<commit_before>#ifndef jak_da_h
#define jak_da_h

/**
 * @file
 * @brief Dynamic array class
 *
 * All functions that return int return 0 on success if not specified otherwise
 */




/**
 * The main dynamic array type. This type should be used as readonly.
 * It is only public so you can access the len and el elements without an accessor function.
 */
typedef struct {
	unsigned int len;
	unsigned int max_len;
	float factor;
	unsigned int el_size;
	void * el;
} jak_da_t;

/**
 * Creates a new dynamic array.
 * The following must be true or pushing to the array will fail with a nice error message :)
 * (int)( initial_size * growth_factor ) > (int)initial_size
 * So for example for the default factor the minimal initial_size is 2.
 * If growth factor is -1.0f then the default value is used ( golden ratio ).
 * Growth factor must be more than 1.0f
 * el_size is the size of the elements. It can be sizeof( void * ) or sizeof( sturct some_struct ) or sizeof( int )
 * The functions then use memcpy to copy the structures where needed ...
 *
 * \Returns NULL on error.
 */
jak_da_t * jak_da_new( unsigned int initial_size, float growth_factor, unsigned int el_size );

/**
 * Frees all the memory associated with the a object created via jak_da_new() and deallocates it.
 */
void jak_da_free( jak_da_t * a );

/**
 * Pushes a new element to the end of the array. Adds +1 to a->len and
 * reallocates/grows the backing memory store if needed.
 */
int jak_da_push( jak_da_t * a, void * el );

/**
 * Pops the last element off the array (attention it doesn't memset() it to NULL!)
 */
int jak_da_pop( jak_da_t * a );

/**
 * Accessor macro for array elements.
 * To access the element at index i of array a use: jak_da_el( a, i )
 */
#define jak_da_get( a, i ) ( ( i < a->len && i >= 0 ) ? ( (void *)( (char *)( a )->el + ( i ) * a->el_size ) ) : NULL )

/**
 * Accessor macro for last element in array.
 */
#define jak_da_last( a ) ( ( a->len > 0  ) ? ( (void *)( (char *)( a )->el + ( a->len - 1 ) * a->el_size ) ) : NULL )

/**
 * Allocates or deallocates place in the array so it contains i members.
 * The lenght is changed and the buffer backing the dynamic array
 * is grown or shrinked according to the growth factor.
 */
int jak_da_resize( jak_da_t * a, unsigned int i );

/**
 * Overwrites the buffer backing the dynamic array with zeros.
 */
void jak_da_zero_out( jak_da_t * a );




#endif
<commit_msg>Removed check for zero or more in jak_da_get() as the index should always be unsigned int<commit_after>#ifndef jak_da_h
#define jak_da_h

/**
 * @file
 * @brief Dynamic array class
 *
 * All functions that return int return 0 on success if not specified otherwise
 */




/**
 * The main dynamic array type. This type should be used as readonly.
 * It is only public so you can access the len and el elements without an accessor function.
 */
typedef struct {
	unsigned int len;
	unsigned int max_len;
	float factor;
	unsigned int el_size;
	void * el;
} jak_da_t;

/**
 * Creates a new dynamic array.
 * The following must be true or pushing to the array will fail with a nice error message :)
 * (int)( initial_size * growth_factor ) > (int)initial_size
 * So for example for the default factor the minimal initial_size is 2.
 * If growth factor is -1.0f then the default value is used ( golden ratio ).
 * Growth factor must be more than 1.0f
 * el_size is the size of the elements. It can be sizeof( void * ) or sizeof( sturct some_struct ) or sizeof( int )
 * The functions then use memcpy to copy the structures where needed ...
 *
 * \Returns NULL on error.
 */
jak_da_t * jak_da_new( unsigned int initial_size, float growth_factor, unsigned int el_size );

/**
 * Frees all the memory associated with the a object created via jak_da_new() and deallocates it.
 */
void jak_da_free( jak_da_t * a );

/**
 * Pushes a new element to the end of the array. Adds +1 to a->len and
 * reallocates/grows the backing memory store if needed.
 */
int jak_da_push( jak_da_t * a, void * el );

/**
 * Pops the last element off the array (attention it doesn't memset() it to NULL!)
 */
int jak_da_pop( jak_da_t * a );

/**
 * Accessor macro for array elements.
 * To access the element at index i of array a use: jak_da_el( a, i )
 */
#define jak_da_get( a, i ) ( ( i < a->len ) ? ( (void *)( (char *)( a )->el + ( i ) * a->el_size ) ) : NULL )

/**
 * Accessor macro for last element in array.
 */
#define jak_da_last( a ) ( ( a->len > 0  ) ? ( (void *)( (char *)( a )->el + ( a->len - 1 ) * a->el_size ) ) : NULL )

/**
 * Allocates or deallocates place in the array so it contains i members.
 * The lenght is changed and the buffer backing the dynamic array
 * is grown or shrinked according to the growth factor.
 */
int jak_da_resize( jak_da_t * a, unsigned int i );

/**
 * Overwrites the buffer backing the dynamic array with zeros.
 */
void jak_da_zero_out( jak_da_t * a );




#endif

{'fraction_non_alphanumeric': 0.10281517747858017, 'fraction_numerical': 0.003875968992248062, 'mean_word_length': 3.285839160839161, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5459926', 'n_tokens_mistral': 1585, 'n_tokens_neox': 1545, 'n_words': 695}