move some big items to heap

ulab-original
jsorg71 15 years ago
parent dd6f1f6926
commit d5e4d708e9

@ -202,12 +202,11 @@ km_read_section(int fd, const char* section_name, struct xrdp_key_info* keymap)
int APP_CC int APP_CC
get_keymaps(int keylayout, struct xrdp_keymap* keymap) get_keymaps(int keylayout, struct xrdp_keymap* keymap)
{ {
int ks;
int fd; int fd;
char filename[256]; char* filename;
struct xrdp_keymap lkeymap; struct xrdp_keymap* lkeymap;
ks = sizeof(int) * 128; filename = (char*)g_malloc(256, 0);
/* check if there is a keymap file */ /* check if there is a keymap file */
g_snprintf(filename, 255, "%s/km-%4.4x.ini", XRDP_CFG_PATH, keylayout); g_snprintf(filename, 255, "%s/km-%4.4x.ini", XRDP_CFG_PATH, keylayout);
if (g_file_exist(filename)) if (g_file_exist(filename))
@ -215,26 +214,26 @@ get_keymaps(int keylayout, struct xrdp_keymap* keymap)
fd = g_file_open(filename); fd = g_file_open(filename);
if (fd > 0) if (fd > 0)
{ {
lkeymap = *keymap; /* make a copy of the build in kaymap */ lkeymap = (struct xrdp_keymap*)g_malloc(sizeof(struct xrdp_keymap), 0);
/* make a copy of the build in kaymap */
g_memcpy(lkeymap, keymap, sizeof(struct xrdp_keymap));
/* clear the keymaps */ /* clear the keymaps */
g_memset(keymap->keys_noshift, 0, ks); g_memset(keymap, 0, sizeof(struct xrdp_keymap));
g_memset(keymap->keys_shift, 0, ks);
g_memset(keymap->keys_altgr, 0, ks);
g_memset(keymap->keys_capslock, 0, ks);
g_memset(keymap->keys_shiftcapslock, 0, ks);
/* read the keymaps */ /* read the keymaps */
km_read_section(fd, "noshift", keymap->keys_noshift); km_read_section(fd, "noshift", keymap->keys_noshift);
km_read_section(fd, "shift", keymap->keys_shift); km_read_section(fd, "shift", keymap->keys_shift);
km_read_section(fd, "altgr", keymap->keys_altgr); km_read_section(fd, "altgr", keymap->keys_altgr);
km_read_section(fd, "capslock", keymap->keys_capslock); km_read_section(fd, "capslock", keymap->keys_capslock);
km_read_section(fd, "shiftcapslock", keymap->keys_shiftcapslock); km_read_section(fd, "shiftcapslock", keymap->keys_shiftcapslock);
if (g_memcmp(&lkeymap, keymap, sizeof(struct xrdp_keymap)) != 0) if (g_memcmp(lkeymap, keymap, sizeof(struct xrdp_keymap)) != 0)
{ {
g_writeln("local keymap file for 0x%4.4x found and dosen't match built \ g_writeln("local keymap file for 0x%4.4x found and dosen't match "
in keymap, using local keymap file", keylayout); "built in keymap, using local keymap file", keylayout);
} }
g_free(lkeymap);
g_file_close(fd); g_file_close(fd);
} }
} }
g_free(filename);
return 0; return 0;
} }

Loading…
Cancel
Save