Commit 44144010 authored by Max Kellermann's avatar Max Kellermann

util/StringStrip: add more "nonnull" attributes

parent ec54754e
/* /*
* Copyright (C) 2009-2017 Max Kellermann <max.kellermann@gmail.com> * Copyright 2009-2018 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
......
/* /*
* Copyright (C) 2009-2017 Max Kellermann <max.kellermann@gmail.com> * Copyright 2009-2018 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -38,32 +38,32 @@ ...@@ -38,32 +38,32 @@
* Returns a pointer to the first non-whitespace character in the * Returns a pointer to the first non-whitespace character in the
* string, or to the end of the string. * string, or to the end of the string.
*/ */
gcc_pure gcc_pure gcc_returns_nonnull gcc_nonnull_all
const char * const char *
StripLeft(const char *p) noexcept; StripLeft(const char *p) noexcept;
gcc_pure gcc_pure gcc_returns_nonnull gcc_nonnull_all
static inline char * static inline char *
StripLeft(char *p) noexcept StripLeft(char *p) noexcept
{ {
return const_cast<char *>(StripLeft((const char *)p)); return const_cast<char *>(StripLeft((const char *)p));
} }
gcc_pure gcc_pure gcc_returns_nonnull gcc_nonnull_all
const char * const char *
StripLeft(const char *p, const char *end) noexcept; StripLeft(const char *p, const char *end) noexcept;
/** /**
* Determine the string's end as if it was stripped on the right side. * Determine the string's end as if it was stripped on the right side.
*/ */
gcc_pure gcc_pure gcc_returns_nonnull gcc_nonnull_all
const char * const char *
StripRight(const char *p, const char *end) noexcept; StripRight(const char *p, const char *end) noexcept;
/** /**
* Determine the string's end as if it was stripped on the right side. * Determine the string's end as if it was stripped on the right side.
*/ */
gcc_pure gcc_pure gcc_returns_nonnull gcc_nonnull_all
static inline char * static inline char *
StripRight(char *p, char *end) noexcept StripRight(char *p, char *end) noexcept
{ {
...@@ -75,13 +75,14 @@ StripRight(char *p, char *end) noexcept ...@@ -75,13 +75,14 @@ StripRight(char *p, char *end) noexcept
* Determine the string's length as if it was stripped on the right * Determine the string's length as if it was stripped on the right
* side. * side.
*/ */
gcc_pure gcc_pure gcc_nonnull_all
size_t size_t
StripRight(const char *p, size_t length) noexcept; StripRight(const char *p, size_t length) noexcept;
/** /**
* Strip trailing whitespace by null-terminating the string. * Strip trailing whitespace by null-terminating the string.
*/ */
gcc_nonnull_all
void void
StripRight(char *p) noexcept; StripRight(char *p) noexcept;
...@@ -89,6 +90,7 @@ StripRight(char *p) noexcept; ...@@ -89,6 +90,7 @@ StripRight(char *p) noexcept;
* Skip whitespace at the beginning and terminate the string after the * Skip whitespace at the beginning and terminate the string after the
* last non-whitespace character. * last non-whitespace character.
*/ */
gcc_returns_nonnull gcc_nonnull_all
char * char *
Strip(char *p) noexcept; Strip(char *p) noexcept;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment