Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don’t worry, you can still create the pull request.
  • 6 commits
  • 4 files changed
  • 0 commit comments
  • 2 contributors
Showing with 33 additions and 6 deletions.
  1. +24 −0 src/common/util.c
  2. +5 −0 src/common/util.h
  3. +1 −1 src/or/config.c
  4. +3 −5 src/or/control.c
View
24 src/common/util.c
@@ -2679,6 +2679,30 @@ tor_sscanf(const char *buf, const char *pattern, ...)
return r;
}
+/** Append the string produced by tor_asprintf(<b>pattern</b>, <b>...</b>)
+ * to <b>sl</b>. */
+void
+smartlist_asprintf_add(struct smartlist_t *sl, const char *pattern, ...)
+{
+ va_list ap;
+ va_start(ap, pattern);
+ smartlist_vasprintf_add(sl, pattern, ap);
+ va_end(ap);
+}
+
+/** va_list-based backend of smartlist_asprintf_add. */
+void
+smartlist_vasprintf_add(struct smartlist_t *sl, const char *pattern,
+ va_list args)
+{
+ char *str = NULL;
+
+ tor_vasprintf(&str, pattern, args);
+ tor_assert(str != NULL);
+
+ smartlist_add(sl, str);
+}
+
/** Return a new list containing the filenames in the directory <b>dirname</b>.
* Return NULL on error or if <b>dirname</b> is not a directory.
*/
View
5 src/common/util.h
@@ -220,6 +220,11 @@ int tor_sscanf(const char *buf, const char *pattern, ...)
#endif
;
+void smartlist_asprintf_add(struct smartlist_t *sl, const char *pattern, ...)
+ CHECK_PRINTF(2, 3);
+void smartlist_vasprintf_add(struct smartlist_t *sl, const char *pattern,
+ va_list args);
+
int hex_decode_digit(char c);
void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen);
int base16_decode(char *dest, size_t destlen, const char *src, size_t srclen);
View
2 src/or/config.c
@@ -718,7 +718,7 @@ set_options(or_options_t *new_val, char **msg)
if (!option_is_same(&options_format, new_val, old_options,
options_format.vars[i].name)) {
line = get_assigned_option(&options_format, new_val,
- options_format.vars[i].name, 0);
+ options_format.vars[i].name, 1);
if (line) {
for (; line; line = line->next) {
View
8 src/or/control.c
@@ -4008,20 +4008,18 @@ control_event_conf_changed(smartlist_t *elements)
int i;
char *result;
smartlist_t *lines;
- if (smartlist_len(elements) == 0) {
+ if (!EVENT_IS_INTERESTING(EVENT_CONF_CHANGED) || smartlist_len(elements) == 0) {
return 0;
}
lines = smartlist_create();
for (i = 0; i < smartlist_len(elements); i += 2) {
char *k = smartlist_get(elements, i);
char *v = smartlist_get(elements, i+1);
- char *tmp;
if (v == NULL) {
- tor_asprintf(&tmp, "650-%s", k);
+ smartlist_asprintf_add(lines, "650-%s", k);
} else {
- tor_asprintf(&tmp, "650-%s=%s", k, v);
+ smartlist_asprintf_add(lines, "650-%s=%s", k, v);
}
- smartlist_add(lines, tmp);
}
result = smartlist_join_strings(lines, "\r\n", 0, NULL);
send_control_event(EVENT_CONF_CHANGED, 0,

No commit comments for this range

Something went wrong with that request. Please try again.