Skip to content
Snippets Groups Projects
Commit 0c0b039c authored by Kostyantyn Vorobyov's avatar Kostyantyn Vorobyov Committed by Julien Signoles
Browse files

New functionality in the string module of RTL

parent 73ef7e4f
No related branches found
No related tags found
No related merge requests found
......@@ -40,13 +40,18 @@
#define E_ACSL_STD_STRING_H
#ifndef E_ACSL_NO_COMPILER_BUILTINS
# define memset __builtin_memset
# define memcmp __builtin_memcmp
# define memcpy __builtin_memcpy
# define memmove __builtin_memmove
# define strlen __builtin_strlen
# define strcmp __builtin_strcmp
# define strncmp __builtin_strncmp
# define memset __builtin_memset
# define memcmp __builtin_memcmp
# define memcpy __builtin_memcpy
# define memmove __builtin_memmove
# define strncat __builtin_strncat
# define strcat __builtin_strcat
# define strlen __builtin_strlen
# define strcmp __builtin_strcmp
# define strncmp __builtin_strncmp
# define strcpy __builtin_strcpy
# define strncpy __builtin_strncpy
# define strchr __builtin_strchr
#else
# include <string.h>
#endif
......@@ -128,4 +133,14 @@ static int zeroed_out(const void *p, size_t size) {
}
return !memcmp(pc, &zeroblock, rem);
}
/** \brief Count the number of occurrences of char `c` in a string `s` */
static int charcount(const char *s, char c) {
int count = 0;
while ((s = strchr(s,c)) != NULL) {
count++;
s++;
}
return count;
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment