Skip to content

Commit

Permalink
a few changes in comments and mains sections
Browse files Browse the repository at this point in the history
  • Loading branch information
mbpassos authored and mbpassos committed May 15, 2023
1 parent 4f64576 commit 7fa7f03
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 34 deletions.
3 changes: 2 additions & 1 deletion lib/ft_calloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: mbrito-p <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/14 20:09:18 by mbrito-p #+# #+# */
/* Updated: 2023/05/14 20:09:18 by mbrito-p ### ########.fr */
/* Updated: 2023/05/15 04:00:29 by mbrito-p ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -20,6 +20,7 @@
// to free(). If the multiplication of nmemb and size
// would result in integer overflow,
// then calloc() returns an error.
//ft_memset(ptr, 0, total_memory_size); avoids unexpected behaviour.
#include "libft.h"

void *ft_calloc(size_t nmemb, size_t size)
Expand Down
1 change: 1 addition & 0 deletions lib/ft_lstadd_back.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// a list.
// new: The address of a pointer to the node to be
// added to the list.
//if (!*lst) checks if its empty.
#include "libft.h"

void ft_lstadd_back(t_list **lst, t_list *new)
Expand Down
1 change: 1 addition & 0 deletions lib/ft_lstdelone.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// the content.
// at the end set lst = NULL to prevent dangling
// (invalid or non-existent) pointer.
// lst = NULL; prevent from using the pointer
#include "libft.h"

void ft_lstdelone(t_list *lst, void (*del)(void*))
Expand Down
1 change: 1 addition & 0 deletions lib/ft_lstmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// del: The address of the function used to delete
// the content of a node if needed.
// Returns: The new list. NULL if the allocation fails.
// ft_lstclear(&new_node, del); prevents memory leaks
#include "libft.h"

t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
Expand Down
16 changes: 0 additions & 16 deletions lib/ft_memset.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,6 @@
// #include <string.h>
// It fills a block of memory (specified by the pointer s and the size n)
// with a constant byte value (c).
// The function first casts the s pointer to an unsigned char
// pointer and assigns it to the ptr variable. This is done to enable
// byte-level manipulation.
// The function then enters a loop that iterates n times.
// The comparison n-- > 0 checks whether n is greater than 0 after the
// decrement. If n is 0 or negative, the loop stops.
// The expression *(ptr++) = (unsigned char)c sets the value of the
// current byte pointed to by ptr to the value of c, and then increments the
// value of ptr by 1. This is done using the dereference operator * to
// access the value at the memory address pointed to by ptr, and then
// the post-increment operator ++ to increment the value of ptr.
// Since c is cast to an unsigned char before being used in the assignment,
// it only sets the value of the current byte, rather than the entire
// int value. This is important because ft_memset is only intended to set
// each byte in the memory area pointed to by s to the same value, not
// to set the entire memory area to the same value as an int.
#include "libft.h"

void *ft_memset(void *s, int c, size_t n)
Expand Down
1 change: 1 addition & 0 deletions lib/ft_strjoin.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// string, which is the result of the concatenation
// of ’s1’ and ’s2’.Return value: The new string.
// NULL if the allocation fails.
//final_str + len1 pointer to where it starts counting
#include "libft.h"

char *ft_strjoin(char const *s1, char const *s2)
Expand Down
17 changes: 0 additions & 17 deletions lib/ft_strlcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,10 @@
// strlcat() is a function that concatenates two strings.
// It takes the full size of the buffer as a parameter (not just the length)
// and guarantees to NUL-terminate the result.
// The function appends string src to the end of dst, but the number
// of characters that it will add is determined by the dstsize
// parameter that you pass to the function.
// strlcat() will always make sure to leave room for a null
// character ('\0') at the end of the string it is building. That's why
// the comment says that it will add:
// "at most dstsize - strlen(dst) - 1 characters". strlen(dst) gives
// you the length of the first string, and the - 1 is there to
// make sure there is room for the null character.
// The function will append at most dstsize - strlen(dst) - 1 characters.
// It will then NUL-terminate the result unless dstsize
// is 0 or the original dst string was longer than dstsize.
// In practice, this should not happen as it means that either dstsize
// is incorrect or that dst is not a proper string.
// If the src and dst strings overlap, the behavior is undefined.
//
// Parameters:
// - dst: the destination string buffer to append to
// - src: the source string to append to the destination string
// - dstsize: the size of the destination buffer
//
// Return value: the total length of the original string and the
// appended string that would have been created if enough
// :space had been available.
Expand Down

0 comments on commit 7fa7f03

Please sign in to comment.