minishell
check_no_opt_str.c File Reference
#include <limits.h>
#include <stddef.h>
#include <stdlib.h>
#include "ft_printf_local.h"
#include "../ft_mem/ft_mem.h"
#include "../ft_math/ft_math.h"
Include dependency graph for check_no_opt_str.c:

Go to the source code of this file.

Functions

t_fmtcheck_no_opt_str (size_t *len, char **fmt, t_fmt *p_ret)
 

Function Documentation

◆ check_no_opt_str()

t_fmt* check_no_opt_str ( size_t *  len,
char **  fmt,
t_fmt p_ret 
)

Definition at line 20 of file check_no_opt_str.c.

21 {
22  size_t str_len;
23 
24  str_len = 0;
25  if (p_ret == NULL)
26  p_ret = ft_calloc(1, sizeof(t_fmt));
27  if (p_ret == NULL)
28  return (p_ret);
29  p_ret->type = STR;
30  p_ret->data.str = *fmt;
31  while (*len <= INT_MAX && **fmt != '\0' && **fmt != '%')
32  {
33  str_len++;
34  *len += 1;
35  *fmt += 1;
36  }
37  if (*len > INT_MAX)
38  {
39  free(p_ret);
40  return (NULL);
41  }
42  p_ret->str_len = (int)str_len;
43  *len += ft_max(p_ret->min_len, p_ret->str_len);
44  return (p_ret);
45 }
void * ft_calloc(size_t count, size_t size)
Definition: ft_calloc.c:29
int ft_max(int a, int b)
Definition: ft_max.c:16
@ STR
t_dtype type
t_data data
int str_len
int min_len
char * str
Here is the call graph for this function:
Here is the caller graph for this function: