|
@@ -225,43 +225,6 @@ add_laplace_noise(int64_t signal_, double random_, double delta_f,
|
|
|
* String manipulation
|
|
|
* ===== */
|
|
|
|
|
|
-
|
|
|
- * character in <b>chars_to_escape</b> is preceded by a backslash. */
|
|
|
-char *
|
|
|
-tor_escape_str_for_pt_args(const char *string, const char *chars_to_escape)
|
|
|
-{
|
|
|
- char *new_string = NULL;
|
|
|
- char *new_cp = NULL;
|
|
|
- size_t length, new_length;
|
|
|
-
|
|
|
- tor_assert(string);
|
|
|
-
|
|
|
- length = strlen(string);
|
|
|
-
|
|
|
- if (!length)
|
|
|
- return tor_strdup("");
|
|
|
-
|
|
|
- (length*2 > SIZE_MAX - 1) => (length > (SIZE_MAX - 1)/2) */
|
|
|
- if (length > (SIZE_MAX - 1)/2)
|
|
|
- return NULL;
|
|
|
-
|
|
|
-
|
|
|
- new_length = (length * 2) + 1;
|
|
|
-
|
|
|
- new_string = new_cp = tor_malloc(new_length);
|
|
|
-
|
|
|
- while (*string) {
|
|
|
- if (strchr(chars_to_escape, *string))
|
|
|
- *new_cp++ = '\\';
|
|
|
-
|
|
|
- *new_cp++ = *string++;
|
|
|
- }
|
|
|
-
|
|
|
- *new_cp = '\0';
|
|
|
-
|
|
|
- return new_string;
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
* Time
|
|
|
* ===== */
|