Compare commits
2 Commits
1baa0a33af
...
c6b32a3543
Author | SHA1 | Date |
---|---|---|
thetek | c6b32a3543 | |
thetek | 0fa391bb43 |
|
@ -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
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,7 +15,7 @@ test_results_t
|
|||
test_cstr (void)
|
||||
{
|
||||
test_group_t group;
|
||||
size_t len;
|
||||
usize len;
|
||||
|
||||
group = test_group_new ();
|
||||
|
||||
|
@ -62,7 +62,7 @@ test_str (void)
|
|||
group = test_group_new ();
|
||||
|
||||
str = str_new ();
|
||||
test_add (&group, test_assert (str.str != NULL && str.cap > 0), "str_new");
|
||||
test_add (&group, test_assert (str.str != nullptr && str.cap > 0), "str_new");
|
||||
str_free (&str);
|
||||
|
||||
str = str_new_cap (1000);
|
||||
|
@ -97,7 +97,7 @@ test_str (void)
|
|||
test_add (&group, test_assert (!str_ends_with (&str, "bar")), "str_ends_with false");
|
||||
|
||||
test_add (&group, test_assert (str_find (&str, "ipsum") == str.str + 6), "str_find success");
|
||||
test_add (&group, test_assert (str_find (&str, "foo") == NULL), "str_find failure");
|
||||
test_add (&group, test_assert (str_find (&str, "foo") == nullptr), "str_find failure");
|
||||
test_add (&group, test_assert (str_pos (&str, "ipsum") == 6), "str_pos success");
|
||||
test_add (&group, test_assert (str_pos (&str, "foo") == -1), "str_pos failure");
|
||||
str_free (&str);
|
||||
|
|
Loading…
Reference in New Issue