diff --git a/glfw/ibus_glfw.c b/glfw/ibus_glfw.c index 9e2bb1777..7d2baa3b2 100644 --- a/glfw/ibus_glfw.c +++ b/glfw/ibus_glfw.c @@ -51,20 +51,6 @@ enum Capabilities { IBUS_CAP_SURROUNDING_TEXT = 1 << 5 }; -// implement strdup ourselves because the various unix/libc flavors all -// require different sets of macros to make it available, and I cannot be -// bothered -static inline char* -strdup(const char *src) { - size_t len = strlen(src); - char *ans = malloc(len + 1); - if (ans) { - memcpy(ans, src, len); - ans[len] = 0; - } - return ans; -} - static inline GLFWbool test_env_var(const char *name, const char *val) { @@ -173,7 +159,7 @@ get_ibus_address_file_name(void) { const char *de = getenv("DISPLAY"); if (!de || !de[0]) de = ":0.0"; - char *display = strdup(de); + char *display = _glfw_strdup(de); const char *host = display; char *disp_num = strrchr(display, ':'); char *screen_num = strrchr(display, '.'); @@ -237,7 +223,7 @@ read_ibus_address(_GLFWIBUSData *ibus) { ibus->address_file_mtime = s.st_mtime; if (found) { free((void*)ibus->address); - ibus->address = strdup(buf + sizeof("IBUS_ADDRESS=") - 1); + ibus->address = _glfw_strdup(buf + sizeof("IBUS_ADDRESS=") - 1); return GLFW_TRUE; } _glfwInputError(GLFW_PLATFORM_ERROR, "Could not find IBUS_ADDRESS in %s", ibus->address_file_name); @@ -254,7 +240,7 @@ input_context_created(DBusMessage *msg, const char* errmsg, void *data) { if (!glfw_dbus_get_args(msg, "Failed to get IBUS context path from reply", DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID)) return; _GLFWIBUSData *ibus = (_GLFWIBUSData*)data; free((void*)ibus->input_ctx_path); - ibus->input_ctx_path = strdup(path); + ibus->input_ctx_path = _glfw_strdup(path); if (!ibus->input_ctx_path) return; dbus_bus_add_match(ibus->conn, "type='signal',interface='org.freedesktop.IBus.InputContext'", NULL); DBusObjectPathVTable ibus_vtable = {.message_function = message_handler}; @@ -274,7 +260,7 @@ setup_connection(_GLFWIBUSData *ibus) { ibus->ok = GLFW_FALSE; if (!address_file_name) return GLFW_FALSE; free((void*)ibus->address_file_name); - ibus->address_file_name = strdup(address_file_name); + ibus->address_file_name = _glfw_strdup(address_file_name); if (!read_ibus_address(ibus)) return GLFW_FALSE; if (ibus->conn) { glfw_dbus_close_connection(ibus->conn);