Xavier Del Campo Romero
7be16e6e5c
CMakeLists.txt: Fix missing parameter names
...
VERSION must be indicated when passing a version string to project().
Also, LANGUAGES must be also be passed when the language name is not the
only argument to project() (apart from the project name itself).
2023-11-10 14:43:39 +01:00
Xavier Del Campo Romero
e7b84e0bf6
Makefile: Set -O1
2023-10-25 22:06:23 +02:00
Xavier Del Campo Romero
67bc69c53e
Makefile: Adhere to GNU Make directory variables
2023-10-25 22:06:23 +02:00
Xavier Del Campo Romero
1a303c69cd
Makefile: Build dynstr also as a shared library
2023-10-25 21:47:34 +02:00
Xavier Del Campo Romero
b2ded0cd62
Makefile: Update copyright year
2023-10-25 21:47:33 +02:00
Xavier Del Campo Romero
de0d0e9fab
CMakeLists.txt: set project VERSION
2023-10-25 14:09:16 +02:00
Xavier Del Campo Romero
c4979825b7
CMakeLists.txt: Stop forcing STATIC library
...
Distribution packagers might prefer dynstr as a shared object.
2023-10-16 01:16:32 +02:00
Xavier Del Campo Romero
cc9eae6d01
Makefile: Fix wrong installation directory
...
Libraries are meant to be placed in $PREFIX/lib, and not $PREFIX/bin.
2023-10-16 00:38:23 +02:00
Xavier Del Campo Romero
ef14ee964a
Install .pc file
2023-10-16 00:38:06 +02:00
Xavier Del Campo Romero
d0d843b704
Support installation
2023-10-02 14:39:43 +02:00
Xavier Del Campo Romero
0e779caae6
CMakeLists.txt: add cmake_minimum_required
...
This command is mandatory for all CMake projects. 3.0 was chosen since
dynstr does not require any newer CMake features.
2023-10-02 14:38:53 +02:00
Xavier Del Campo Romero
58bd7d9376
CMakeLists.txt: Set project language to C
...
Otherwise, CMake tests the system C++ compiler by default, which is not
a requirement for dynstr.
2023-08-02 13:06:08 +02:00
Xavier Del Campo Romero
57c9dfcfd0
Makefile: add clean target
2023-08-01 02:19:13 +02:00
Xavier Del Campo Romero
5c13c9b838
Support POSIX make(1) as build system
2023-05-28 11:36:47 +02:00
Xavier Del Campo Romero
909d716a1e
dynstr.c: Fix memory leak if realloc(3) fails
...
According to C99 §7.20.3.4:
If memory for the new object cannot be allocated, the old object is not
deallocated and its value is unchanged.
Therefore, a temporary pointer must be used to ensure the original
object can still be deallocated should realloc(3) return a null pointer.
2023-03-08 01:21:16 +01:00
Xavier Del Campo Romero
8e7557ef7a
dynstr.c: Make zero-initialization portable
2023-03-08 01:19:21 +01:00
Xavier Del Campo Romero
0f2bf85be8
Update copyright notice
2023-03-08 01:18:47 +01:00
Xavier Del Campo Romero
601a813325
Fix lifetime issues with va_list
...
The standard requires both va_start and va_end to be called from the
same function. On the other hand, vsnprintf and vsprintf leave the
va_list on an undefined state according to the standard, so a copy must
be created before a second call to these functions.
2020-10-14 08:27:19 +02: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
9bf483cde2
Updated README.md with dynstr_prepend example
2020-08-04 20:01:11 +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
3b94bbd2bd
Added license notice to CMakeLists.txt, used PROJECT_NAME
2020-07-26 14:37:57 +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
9c8d949cd1
Added CMakeLists.txt for other projects to use
2020-07-09 16:41:41 +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
Xavier Del Campo Romero
357d4f2c0f
Avoid free() if no string is present
2020-03-25 10:48:54 +01:00
Xavier Del Campo Romero
46d7c1715b
Removed esp-idf files
2020-03-23 14:51:47 +01: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
35497efab9
Merge branch 'master' of https://github.com/XaviDCR92/dynstr
2020-03-21 09:54:04 +01:00
XaviDCR92
f0bf3175ab
Added compile-time error when C99 is not present
2020-03-21 09:53:45 +01:00
Xavi Del Campo
92409d275f
Solved compiler error by adding scope block
2020-03-21 01:09:43 +01:00
Xavier Del Campo Romero
278517ee1e
Build files for esp-idf
2020-03-20 16:22:36 +01:00
Xavier Del Campo Romero
7c5af7734a
New convenience macro dynstr_append_or_ret_zero
2020-03-20 09:47:47 +01:00
Xavier Del Campo Romero
67ee01d77c
Replaced unneeded calloc() by malloc()
2020-03-20 09:25:58 +01:00
Xavi Del Campo
73dd849484
First commit
2020-03-19 18:40:31 +01:00