Commit Graph

20 Commits

Author SHA1 Message Date
Xavier Del Campo Romero 0f2bf85be8 Update copyright notice 2023-03-08 01:18:47 +01:00
Xavier Del Campo Romero 837c9427de Add missing do/while (0) on convenience macros 2020-10-08 11:24:31 +02:00
Xavier Del Campo Romero 083eca5323 Move convenience macros down for readability 2020-10-08 11:24:31 +02:00
Xavier Del Campo Romero 3e9016f23f Add convenience macros for dynstr_prepend 2020-10-08 11:24:31 +02:00
Xavier Del Campo Romero c862d84d0b Add dynstr_vprepend 2020-10-08 11:24:24 +02:00
Xavier Del Campo Romero 8bd1123857 Add dynstr_vappend 2020-10-06 09:20:57 +02:00
Xavier Del Campo Romero e0eaf50fdc Avoid exceeding 80-column per line 2020-09-03 15:51:00 +02:00
Xavier Del Campo Romero 4c7bfbf87f Avoid potential undesirable effects caused by macros
The macros provided by this library would expand to an unguarded
conditional that could have potential unwanted consequences. Consider
the following example:

    dynstr_append_or_ret_null(&d, "example");
    else
    {
        /* This is unexpectedly working. */
    }

The example above would expand to:

    if (dynstr_append(__VA_ARGS__) != DYNSTR_OK) return false;
    else
    {
        /* This is unexpectedly working. */
    }

Which is valid C yet allows possibly unexpected behaviour. The solution
is then to enclose these conditions into a `do while (0)` statement.
2020-09-03 15:42:56 +02:00
Xavier Del Campo Romero 9b85c4beaa Rephrase documentation to avoid confusion 2020-09-03 15:42:52 +02:00
Xavier Del Campo Romero 134ebfa751 Call dynstr_init on dynstr_free 2020-09-03 14:43:02 +02:00
Xavier Del Campo Romero fe3c74983c dynstr_prepend(), fixed typo in comment 2020-08-03 23:47:18 +02:00
Xavier Del Campo Romero c597344eb7 Added convenience macro dynstr_append_or_ret_nonzero 2020-07-26 04:03:12 +02:00
Xavier Del Campo Romero 2b01e38ca2 Various minor changes
- Removed trailing ';' from convenience macros.
- Convenience macros did not really need the ## __VA_ARGS__ extension.
Simply grouping all parameters into '...', while decreasing readability,
solves the portability issue.
- Added C99 check to dynstr.c.
2020-06-12 10:27:12 +02:00
Xavi Del Campo 03ccf53b26 Minor change 2020-03-21 22:56:23 +01:00
Xavi Del Campo d4fc339810 Added comments to dynstr_dup() 2020-03-21 20:11:06 +01:00
XaviDCR92 34643b8a8d Various changes and improvements
- Replaced int by specific, more meaningful error codes.
- C99 states realloc can be safely called using NULL pointers.
- New function dynstr_dup().
2020-03-21 13:14:48 +01:00
XaviDCR92 0cc52ff5be Fixed typo 2020-03-21 10:07:39 +01:00
XaviDCR92 f0bf3175ab Added compile-time error when C99 is not present 2020-03-21 09:53:45 +01:00
Xavier Del Campo Romero 7c5af7734a New convenience macro dynstr_append_or_ret_zero 2020-03-20 09:47:47 +01:00
Xavi Del Campo 73dd849484 First commit 2020-03-19 18:40:31 +01:00