Rank 03 — 42 Exam

Total: 10/8. PASS.

Forgetting that base can be 2, 8, 10, 16, but not 1 or >16 per subject. Also, value can be negative only for base 10. 4. ft_btree_insert_data (Hard) void ft_btree_insert_data(t_btree **root, void *item, int (*cmpf)()) 42 Exam Rank 03

> 1 (to start ex00)

| Mistake | Consequence | Prevention | |---------|------------|------------| | Forgetting to include #include <stdlib.h> | Implicit function declaration → Moulinette fails | Write includes at top | | Memory leak in list remove_if | Fails strict test | Always free removed node | | Not handling NULL input | Segmentation fault in tests | Check if (!list) return | | Using recursion for deep lists | Stack overflow (not tested but bad style) | Use iteration for long lists | | Modifying original pointer without pointer-to-pointer | Head lost | Use t_list ** when head can change | | ft_itoa_base INT_MIN bug | Wrong output for -2147483648 | Special case: convert to unsigned | | Not checking base bounds | Undefined behavior → fails | if (base < 2 \|\| base > 16) return (NULL); | Recursion Cheat Sheet for Rank 03 Pattern 1: Traversal (no return value) void traverse(t_btree *node) Total: 10/8

t_list *current = *begin_list; t_list *previous = NULL; while (current) Also, value can be negative only for base 10

Good luck, and may your pointers never be dangling!

You might also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More