+ ssnprintf (callback_name, sizeof (callback_name), "memcached/%s",
+ (st->name != NULL) ? st->name : "__legacy__");
+
+ /* If no <Address> used then:
+ * - connect to destination, specified by <Host>, if it presents.
+ * - Keep default hostname, if any:
+ * - Legacy mode is used (no configuration options at all);
+ * - "Host" option is not provided;
+ * - "Host" option is set to "localhost" or "127.0.0.1".
+ *
+ * If <Address> used then host may be set to "localhost"
+ * or "127.0.0.1" explicitly.
+ */
+ if (st->connhost == NULL)
+ {
+ if (st->host)
+ {
+ st->connhost = strdup(st->host);
+ if (st->connhost == NULL)
+ return (ENOMEM);
+
+ if ((strcmp ("127.0.0.1", st->host) == 0)
+ || (strcmp ("localhost", st->host) == 0))
+ sfree(st->host);
+ }
+ else
+ {
+ st->connhost = strdup(MEMCACHED_DEF_HOST);
+ if (st->connhost == NULL)
+ return (ENOMEM);
+ }
+ }
+
+ if (st->connport == NULL)
+ {
+ st->connport = strdup(MEMCACHED_DEF_PORT);
+ if (st->connport == NULL)
+ return (ENOMEM);
+ }
+
+ assert (st->connhost != NULL);
+ assert (st->connport != NULL);