Skip to content

Instantly share code, notes, and snippets.

About null guards in libft, ft_printf, etc (School 42)

Currently, at our campus, there are a lot of people that would fail you if you don't have null guards in libft or ft_printf functions. I very much disagree and wanted to outline some reasons as to why.

Fail loud, not quiet

If ft_split receives NULL, something is deeply wrong with the caller's program. A segfault makes that visible immediately. A silent return hides the bug and lets it propagate somewhere harder to debug.

Segfault is a problem in a binary, not library