sfree(p);
void *open_settings_w(const char *sessionname, char **errmsg){    HKEY subkey1, sesskey;    int ret;    char *p;    *errmsg = NULL;    if (!sessionname || !*sessionname)	sessionname = "Default Settings";    p = snewn(3 * strlen(sessionname) + 1, char);    mungestr(sessionname, p);    ret = RegCreateKey(HKEY_CURRENT_USER, puttystr, &subkey1);    if (ret != ERROR_SUCCESS) {	sfree(p);        *errmsg = dupprintf("Unable to create registry key\n"                            "HKEY_CURRENT_USER\\%s", puttystr);	return NULL;    }    ret = RegCreateKey(subkey1, p, &sesskey);    sfree(p);    RegCloseKey(subkey1);    if (ret != ERROR_SUCCESS) {        *errmsg = dupprintf("Unable to create registry key\n"                            "HKEY_CURRENT_USER\\%s\\%s", puttystr, p);	return NULL;    }    return (void *) sesskey;}