From ae96df0cae20ccb1225a0dc305b4779427506608 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 8 Jul 2020 19:08:58 +0200 Subject: Add a couple of `restrict` --- src/sp_utils.c | 15 +++++++++------ src/sp_utils.h | 11 ++++++----- 2 files changed, 15 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/sp_utils.c b/src/sp_utils.c index ed5123e..8c64b55 100644 --- a/src/sp_utils.c +++ b/src/sp_utils.c @@ -22,7 +22,8 @@ const char* get_ipaddr() { return default_ipaddr; } -void sp_log_msg(char const* feature, int type, const char* fmt, ...) { +void sp_log_msg(char const* restrict feature, int type, + const char* restrict fmt, ...) { char* msg; va_list args; @@ -52,7 +53,8 @@ void sp_log_msg(char const* feature, int type, const char* fmt, ...) { } } -int compute_hash(const char* const filename, char* file_hash) { +int compute_hash(const char* const restrict filename, + char* restrict file_hash) { unsigned char buf[1024]; unsigned char digest[SHA256_SIZE]; PHP_SHA256_CTX context; @@ -78,8 +80,9 @@ int compute_hash(const char* const filename, char* file_hash) { return SUCCESS; } -static int construct_filename(char* filename, const zend_string* folder, - const zend_string* textual) { +static int construct_filename(char* filename, + const zend_string* restrict folder, + const zend_string* restrict textual) { PHP_SHA256_CTX context; unsigned char digest[SHA256_SIZE] = {0}; char strhash[65] = {0}; @@ -103,8 +106,8 @@ static int construct_filename(char* filename, const zend_string* folder, return 0; } -int sp_log_request(const zend_string* folder, const zend_string* text_repr, - char* from) { +int sp_log_request(const zend_string* restrict folder, + const zend_string* restrict text_repr, char* from) { FILE* file; const char* current_filename = zend_get_executed_filename(TSRMLS_C); const int current_line = zend_get_executed_lineno(TSRMLS_C); diff --git a/src/sp_utils.h b/src/sp_utils.h index 6fc59e5..8d1d44a 100644 --- a/src/sp_utils.h +++ b/src/sp_utils.h @@ -44,9 +44,10 @@ #define GET_SUFFIX(x) (x == 1) ? "st" : ((x == 2) ? "nd" : "th") -const char* get_ipaddr(); -void sp_log_msg(char const *feature, int type, const char *fmt, ...); -int compute_hash(const char *const filename, char *file_hash); +const char *get_ipaddr(); +void sp_log_msg(char const *restrict feature, int type, + const char *restrict fmt, ...); +int compute_hash(const char *const restrict filename, char *restrict file_hash); const zend_string *sp_zval_to_zend_string(const zval *); bool sp_match_value(const zend_string *, const zend_string *, const sp_pcre *); bool sp_match_array_key(const zval *, const zend_string *, const sp_pcre *); @@ -58,8 +59,8 @@ void sp_log_disable_ret(const char *restrict, const zend_string *restrict, int hook_function(const char *, HashTable *, zif_handler); int hook_regexp(const sp_pcre *, HashTable *, zif_handler); bool check_is_in_eval_whitelist(const zend_string *const function_name); -int sp_log_request(const zend_string *folder, const zend_string *text_repr, - char *from); +int sp_log_request(const zend_string *restrict folder, + const zend_string *restrict text_repr, char *from); bool sp_zend_string_equals(const zend_string *s1, const zend_string *s2); #endif /* SP_UTILS_H */ -- cgit v1.3