--- a/docs/Writerside/topics/list.h.md Tue Mar 11 11:10:19 2025 +0100 +++ b/docs/Writerside/topics/list.h.md Tue Mar 11 12:05:01 2025 +0100 @@ -36,6 +36,11 @@ > When you create a list which is storing pointers and do not specify a compare function, `cx_cmp_ptr` will be used by default. +> If you want to lazy-initialize lists, you can use the global `cxEmptyList` symbol as a placeholder instead of using a `NULL`-pointer. +> While you *must not* insert elements into that list, you can safely access this list or create iterators. +> This allows you to write clean code without checking for `NULL`-pointer everywhere. +> You still need to make sure that the placeholder is replaced with an actual list before inserting elements. + ## Example In the following example we create a linked-list of regular expressions for filtering data. @@ -100,12 +105,7 @@ However, it should be clear by now that using `CX_STORE_POINTERS` is a bad choice for this use case to begin with. As a rule of thumb: if you allocate memory for an element that you immediately put into the list, consider storing the element directly. -And if you are getting pointers to already allocated memory from somewhere else, and you just want to organize those elements in a list, then consider using `CX_STORE_POINTERS`. - -> If you want to lazy-initialize lists, you can use the global `cxEmptyList` symbol as a placeholder instead of using a `NULL`-pointer. -> While you *must not* insert elements into that list, you can safely access this list or create iterators. -> This allows you to write clean code without checking for `NULL`-pointer everywhere. -> You still need to make sure that the placeholder is replaced with an actual list before inserting elements. +And if you are getting pointers to already allocated memory from somewhere else, and you just want to organize those elements in a list, then consider using `CX_STORE_POINTERS`. ## Insert