Use restrict on pointers where it makes sense. (requires C99 support,
which we already assume)
This commit is contained in:
@@ -47,7 +47,7 @@ void uc_dstr_destroy(struct DStr *str);
|
||||
*
|
||||
* @return 0 if success, != 0 if allocation fails
|
||||
*/
|
||||
int uc_dstr_copy(struct DStr *dest, const struct DStr *src);
|
||||
int uc_dstr_copy(struct DStr *restrict dest, const struct DStr *restrict src);
|
||||
|
||||
/**
|
||||
* @return the available/unused tail bytes in the string.
|
||||
@@ -95,7 +95,7 @@ char *uc_dstr_put(struct DStr *str, size_t len);
|
||||
* @param is_x ctype.h compatible function to use as a filter.
|
||||
* @return number of chars appended
|
||||
*/
|
||||
size_t uc_dstr_put_str_filter(struct DStr *str, const char *s, int (*is_x)(int c));
|
||||
size_t uc_dstr_put_str_filter(struct DStr *str, const char *restrict s, int (*is_x)(int c));
|
||||
|
||||
/* Append a string of the give size.
|
||||
* (The nul terminator is not appended)
|
||||
@@ -104,14 +104,14 @@ size_t uc_dstr_put_str_filter(struct DStr *str, const char *s, int (*is_x)(int c
|
||||
* @param len bytes to append (not including the nul terminator)
|
||||
* @return 0 on success (!= 0 if an allocation fail)
|
||||
*/
|
||||
int uc_dstr_put_str_sz(struct DStr *str, const char *s, size_t len);
|
||||
int uc_dstr_put_str_sz(struct DStr *str, const char *restrict s, size_t len);
|
||||
|
||||
/* Append a string.
|
||||
* (The nul terminator is not appended)
|
||||
*
|
||||
* @return 0 on success (!= 0 if an allocation fail)
|
||||
*/
|
||||
int uc_dstr_put_str(struct DStr *str, const char *s);
|
||||
int uc_dstr_put_str(struct DStr *str, const char *restrict s);
|
||||
|
||||
/* Append a single char.
|
||||
*
|
||||
@@ -122,7 +122,7 @@ int uc_dstr_put_char(struct DStr *str, char c);
|
||||
/* Make the DStr take ownership of the given dynamically allocated string.
|
||||
* Any existing string in the DStr is freed.
|
||||
*/
|
||||
void uc_dstr_own(struct DStr *str, char *s);
|
||||
void uc_dstr_own(struct DStr *str, char *restrict s);
|
||||
|
||||
/** Release the managed string.
|
||||
* The caller is now responsible for managing/free'ing the returned string.
|
||||
@@ -133,7 +133,7 @@ void uc_dstr_own(struct DStr *str, char *s);
|
||||
char *uc_dstr_steal(struct DStr *str);
|
||||
|
||||
/** Swap the A and B DStr */
|
||||
void uc_str_swap(struct DStr *a, struct DStr *b);
|
||||
void uc_str_swap(struct DStr *restrict a, struct DStr *restrict b);
|
||||
|
||||
/** Replace all occurences in the DStr
|
||||
* (This may be used to replace any embedded nul bytes too)
|
||||
@@ -149,10 +149,10 @@ size_t uc_dstr_replace(struct DStr *str, char f, char r);
|
||||
void uc_dstr_trim(struct DStr *str);
|
||||
|
||||
/** Append formatted string (just as sprintf)*/
|
||||
int uc_dstr_sprintf(struct DStr *str, const char *fmt, ...) __attribute__((format(printf,2,3)));
|
||||
int uc_dstr_sprintf(struct DStr *str, const char *restrict fmt, ...) __attribute__((format(printf,2,3)));
|
||||
|
||||
/** va_list variant */
|
||||
int uc_dstr_vsprintf(struct DStr *str, const char *fmt, va_list ap_)__attribute__((format(printf,2,0)));
|
||||
int uc_dstr_vsprintf(struct DStr *str, const char *restrict fmt, va_list ap_)__attribute__((format(printf,2,0)));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user