Commit Graph

16 Commits

Author SHA1 Message Date
Daniel Lange 94ad111391 Update license headers to explicitly say GPLv2+ 2021-09-22 14:28:19 +02:00
Christian Göttsche bf395e10c5 Add xReallocArrayZero() helper
Add helper function to reallocate an dynamic allocated array including
zeroing the newly allocated memory.
2021-09-11 00:04:00 +02:00
Christian Göttsche c243db0b2c XUtils: move implementation of String_contains_i out of header file
The function strcasestr(3) is only available if _GNU_SOURCE is defined.
If any file includes <string.h> before declaring _GNU_SOURCE, e.g by
including "config.h", compilation fails with the following error:

    In file included from ColumnsPanel.c:8:
    In file included from ./ColumnsPanel.h:12:
    In file included from ./Panel.h:13:
    In file included from ./CRT.h:16:
    In file included from ./Settings.h:17:
    In file included from ./Process.h:15:
    In file included from ./Object.h:17:
    ./XUtils.h:42:11: error: implicit declaration of function 'strcasestr' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
       return strcasestr(s1, s2) != NULL;
              ^
    ./XUtils.h:42:11: note: did you mean 'strcasecmp'?
    /usr/include/strings.h:116:12: note: 'strcasecmp' declared here
    extern int strcasecmp (const char *__s1, const char *__s2)
               ^

Move the implementation to avoid unnecessary includes.
Since LTO is quite common and stable performance should not be impacted
if used.
2021-08-25 09:54:30 +02:00
Benny Baumann 976c6123f4 Pointer indication aligned to typename 2021-07-15 06:57:24 +02:00
Christian Göttsche e6d536dd3f Add compiler hints on memory allocating utility functions 2021-01-11 21:08:58 +01:00
Christian Göttsche 70f48f1f44 Add wrapper function for free and strdup
Reduces code in callers and helps avoiding memory leaks.
2021-01-11 20:12:34 +01:00
Christian Göttsche a118928dee XUtils: add safe strncpy implementation
The standard strncpy fails to null-terminate the destination in case
the source is longer than the passed size.
2021-01-11 20:12:34 +01:00
Christian Göttsche 8c8149d146 XUtils: check for multiplication overflow in allocation size 2021-01-02 22:35:13 +01:00
Christian Göttsche d9224c66a4 Use size_t as len type for xSnprintf
Like the C snprintf function
2020-12-06 16:03:44 +01:00
Christian Göttsche 7ba25aa3c4 IWYU update 2020-12-06 15:32:16 +01:00
Christian Göttsche f7a8952933 Add xReadfile wrapper for reading small to medium size files
Inspired by proposed Linux syscall

Avoid file descriptor leaks like 4af8c63f
2020-12-02 20:39:36 +01:00
Benny Baumann 61e14d4bb2 Spacing around operators 2020-11-02 22:15:01 +01:00
Christian Göttsche 4c66eb6d4c XUtils string related updates
- allow count out-parameter of String_split() to be NULL
- introduce xStrndup()
- do not allow NULL pointers passed to String_eq()
  it is not used in any code
- implement String_startsWith(), String_contains_i() and String_eq()
  as inline header functions
- adjust several conversion issues
2020-10-19 15:38:45 +02:00
Benny Baumann 0f5262917f Make all required includes explicit
Information as seen by IWYU 0.12 + clang 9 on Linux
2020-10-18 20:09:05 +02:00
Benny Baumann 5e4b182616 Combine XAlloc.[ch] into XUtils.[ch] 2020-10-17 20:54:14 +02:00
Benny Baumann 872e542f4e Rename StringUtils.[ch] to XUtils.[ch] 2020-10-16 20:30:21 +02:00