Merge branch 'fix-reload-assignments' into next

This commit is contained in:
Michael Stapelberg 2011-09-11 23:42:12 +01:00
commit 355082a74c
6 changed files with 137 additions and 89 deletions

View File

@ -148,7 +148,7 @@ struct Ignore_Event {
*
*/
struct regex {
const char *pattern;
char *pattern;
pcre *regex;
pcre_extra *extra;
};

View File

@ -28,4 +28,10 @@ void match_copy(Match *dest, Match *src);
*/
bool match_matches_window(Match *match, i3Window *window);
/**
* Frees the given match. It must not be used afterwards!
*
*/
void match_free(Match *match);
#endif

View File

@ -17,6 +17,12 @@
*/
struct regex *regex_new(const char *pattern);
/**
* Frees the given regular expression. It must not be used afterwards!
*
*/
void regex_free(struct regex *regex);
/**
* Checks if the given regular expression matches the given input and returns
* true if it does. In either case, it logs the outcome using LOG(), so it will

View File

@ -280,15 +280,19 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
SLIST_REMOVE(&modes, mode, Mode, modes);
}
#if 0
struct Assignment *assign;
while (!TAILQ_EMPTY(&assignments)) {
assign = TAILQ_FIRST(&assignments);
FREE(assign->windowclass_title);
if (assign->type == A_TO_WORKSPACE)
FREE(assign->dest.workspace);
else if (assign->type == A_TO_OUTPUT)
FREE(assign->dest.output);
else if (assign->type == A_COMMAND)
FREE(assign->dest.command);
match_free(&(assign->match));
TAILQ_REMOVE(&assignments, assign, assignments);
FREE(assign);
}
#endif
/* Clear workspace names */
#if 0

View File

@ -136,3 +136,23 @@ bool match_matches_window(Match *match, i3Window *window) {
return true;
}
/*
* Frees the given match. It must not be used afterwards!
*
*/
void match_free(Match *match) {
/* First step: free the regex fields / patterns */
regex_free(match->title);
regex_free(match->application);
regex_free(match->class);
regex_free(match->instance);
regex_free(match->mark);
/* Second step: free the regex helper struct itself */
FREE(match->title);
FREE(match->application);
FREE(match->class);
FREE(match->instance);
FREE(match->mark);
}

View File

@ -49,6 +49,18 @@ struct regex *regex_new(const char *pattern) {
return re;
}
/*
* Frees the given regular expression. It must not be used afterwards!
*
*/
void regex_free(struct regex *regex) {
if (!regex)
return;
FREE(regex->pattern);
FREE(regex->regex);
FREE(regex->extra);
}
/*
* Checks if the given regular expression matches the given input and returns
* true if it does. In either case, it logs the outcome using LOG(), so it will