rem: if (instance) free(instance); if (class) free(class);
add: if (instance) wfree(instance); if (class) wfree(class);
context: wSessionRestoreState(WScreen *scr){    WSavedState *state;    char *instance, *class, *command, *host;    proplist_t win_info, apps, cmd, value;    pid_t pid;    int i, count;    WDock *dock;    WAppIcon *btn=NULL;    int j, n, found;    char *tmp;    make_keys();    if (!scr->session_state)        return;    PLSetStringCmpHook(NULL);    apps = PLGetDictionaryEntry(scr->session_state, sApplications);    if (!apps)        return;    count = PLGetNumberOfElements(apps);    if (count==0)         return;    for (i=0; i<count; i++) {        win_info = PLGetArrayElement(apps, i);        cmd = PLGetDictionaryEntry(win_info, sCommand);        if (!cmd || !PLIsString(cmd) || !(command = PLGetString(cmd))) {            continue;        }        value = PLGetDictionaryEntry(win_info, sName);        if (!value)            continue;        ParseWindowName(value, &instance, &class, "session");        if (!instance && !class)            continue;        value = PLGetDictionaryEntry(win_info, sHost);        if (value && PLIsString(value))            host = PLGetString(value);        else            host = NULL;        state = getWindowState(scr, win_info);        dock = NULL;        value = PLGetDictionaryEntry(win_info, sDock);        if (value && PLIsString(value) && (tmp = PLGetString(value))!=NULL) {            if (sscanf(tmp, "%i", &n)!=1) {                if (!strcasecmp(tmp, "DOCK")) {                    dock = scr->dock;                } else {                    for (j=0; j < scr->workspace_count; j++) {                        if (strcmp(scr->workspaces[j]->name, tmp)==0) {                            dock = scr->workspaces[j]->clip;                            break;                        }                    }                }            } else {                if (n == 0) {                    dock = scr->dock;                } else if (n>0 && n<=scr->workspace_count) {                    dock = scr->workspaces[n-1]->clip;                }            }        }        found = 0;        if (dock!=NULL) {            for (j=0; j<dock->max_icons; j++) {                btn = dock->icon_array[j];                if (btn && SAME(instance, btn->wm_instance) &&                    SAME(class, btn->wm_class) &&                    SAME(command, btn->command) &&		    !btn->launching) {                    found = 1;                    break;                }            }        }        if (found) {            wDockLaunchWithState(dock, btn, state);        } else if ((pid = execCommand(scr, command, host)) > 0) {            wWindowAddSavedState(instance, class, command, pid, state);        } else {            free(state);        }        if (instance) free(instance);        if (class) free(class);    }    /* clean up */    PLSetStringCmpHook(StringCompareHook);}