aboutsummaryrefslogtreecommitdiff
path: root/libft/src/vec/ft_vecpush.c
blob: 026ae3d17534cb1c8c09100fc58cc2198d722904 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_vecpush.c                                       :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: charles <charles.cabergs@gmail.com>        +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/01 19:22:20 by charles           #+#    #+#             */
/*   Updated: 2020/04/02 10:51:38 by charles          ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "libft_vec.h"

/*
** \brief         Push element at the end of vector
** \param vec     Vector where element will be pushed
** \param pushed  Element to push
** \return        Passed vector or NULL if couldnt grow vector
*/

t_ftvec		*ft_vecpush(t_ftvec *vec, void *pushed)
{
	if (vec->capacity <= vec->size)
		if (ft_vecgrow(vec) == NULL)
			return (NULL);
	vec->data[vec->size] = pushed;
	vec->size++;
	return (vec);
}