/* Appends/increments a number to name/instance in case of collision.  */
static char* _mdns_mangle_name(char *in)
/* Appends/increments a number to name/instance in case of collision.  */
static char* _mdns_mangle_name(char *in)
{
        suffix = 2;
    } else {
        char *endp = NULL;
        suffix = strtol(p + 1, &endp, 10);
        if (*endp != 0) {
            suffix = 2;
            p = NULL;
        }
    }
    char *ret;
    if (p == NULL) {
        ret = malloc(strlen(in) + 3);
        if (ret == NULL) {
            HOOK_MALLOC_FAILED;
            return NULL;
        }
        sprintf(ret, "%s-2", in);
    } else {
        ret = malloc(strlen(in) + 2);
        if (ret == NULL) {
            HOOK_MALLOC_FAILED;
            return NULL;
        }
        strcpy(ret, in);
        int baseLen = p - in;
        sprintf(ret + baseLen, "-%d", suffix + 1);
    }
    return ret;
}