refactor: use nullptr instead of NULL

This commit is contained in:
thetek 2023-04-25 13:20:59 +02:00
parent 1baa0a33af
commit 0fa391bb43
4 changed files with 8 additions and 8 deletions

View File

@ -29,7 +29,7 @@ void *
srealloc (void *ptr, usize size)
{
#if __STDC_VERSION__ >= 202000L // C23 or above
if (ptr == NULL)
if (ptr == nullptr)
return smalloc (size);
#endif

View File

@ -11,7 +11,7 @@
* @param file: the file in which malloc() was called
* @param line: the source code line where malloc() was called
*
* @return the pointer to the allocated memory, or NULL in case of error
* @return the pointer to the allocated memory, or nullptr in case of error
*
* @errno see malloc(3)
*
@ -47,7 +47,7 @@ debug_malloc (usize size, const char *file, usize line)
* @param file: the file in which realloc() was called
* @param line: the source code line where realloc() was called
*
* @return the pointer to the reallocated memory, or NULL in case of error
* @return the pointer to the reallocated memory, or nullptr in case of error
*
* @errno see realloc(3)
*
@ -109,7 +109,7 @@ debug_free (void *ptr, const char *file, usize line)
* @param file: the file in which malloc() was called
* @param line: the source code line where malloc() was called
*
* @return the pointer to the allocated memory, or NULL in case of error
* @return the pointer to the allocated memory, or nullptr in case of error
*
* @usage the header `debug.h` defines a macro `smalloc(size)` that
* automatically inserts filename and line.
@ -135,7 +135,7 @@ debug_smalloc (usize size, const char *file, usize line)
* @param file: the file in which realloc() was called
* @param line: the source code line where realloc() was called
*
* @return the pointer to the reallocated memory, or NULL in case of error
* @return the pointer to the reallocated memory, or nullptr in case of error
*
* @usage the header `debug.h` defines a macro `srealloc(ptr, size)` that
* automatically inserts filename and line.

View File

@ -240,7 +240,7 @@ str_ends_with_len (const str_t str[static 1], usize len,
* @param str: the str_t string to search in
* @param find: the cstring to search for
*
* @return beginning of found substring as pointer, or NULL if not found
* @return beginning of found substring as pointer, or nullptr if not found
*/
inline char *
str_find (const str_t str[static 1], const char *find)

View File

@ -18,7 +18,7 @@ test_suite_new (void)
suite = (test_suite_t) {0};
suite.entries = smalloc ((sizeof *(suite.entries)) * TEST_GROUP_ENTRIES_ALLOC);
suite.entries[0] = NULL;
suite.entries[0] = nullptr;
suite.entries_cap = TEST_GROUP_ENTRIES_ALLOC;
return suite;
@ -51,7 +51,7 @@ test_suite_add (test_suite_t suite[static 1], test_entry_func_t func)
}
suite->entries[suite->entries_len] = func;
suite->entries_len += 1;
suite->entries[suite->entries_len] = NULL;
suite->entries[suite->entries_len] = nullptr;
}
/**