/*
** EPITECH PROJECT, 2018
** task01
** File description:
** I do task
*/
#include <stdlib.h>
#include <alloca.h>
#include "lib/my_string.h"

char *my_strdup(char const *s)
{
    char *str;
    ssize_t len;

    len = -1;
    while (s[++len] != '\0');
    str = (char*)malloc(len + 1);
    len = -1;
    while (s[++len] != '\0')
        str[len] = s[len];
    str[len] = '\0';
    return (str);
}

char *my_strndup(char const *s, size_t n)
{
    char *str;
    ssize_t i;

    i = -1;
    while (++i < (ssize_t)n && s[i] != '\0');
    str = (char*)malloc(i + 1);
    i = -1;
    while (++i < (ssize_t)n && s[i] != '\0')
        str[i] = s[i];
    str[i] = '\0';
    return (str);
}

char *my_strdupa(char const *s)
{
    char *str;
    ssize_t len;

    len = -1;
    while (s[++len] != '\0');
    str = (char*)alloca(len + 1);
    len = -1;
    while (s[++len] != '\0')
        str[len] = s[len];
    str[len] = '\0';
    return (str);
}

char *my_strndupa(char const *s, size_t n)
{
    char *str;
    ssize_t i;

    i = -1;
    while (++i < (ssize_t)n && s[i] != '\0');
    str = (char*)alloca(i + 1);
    i = -1;
    while (++i < (ssize_t)n && s[i] != '\0')
        str[i] = s[i];
    str[i] = '\0';
    return (str);
}
