X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;ds=inline;f=actions.c;h=4257acc1ca950ac2e297b3f77032dc7b057096dc;hb=f4107f65b676b63a199fe4230e58695757f9f199;hp=2fb546f430e16e8c80a3b6d04e3ec83f2bd66ff3;hpb=5ee3e711d51e9fc40564f25fed2dccde2c76656c;p=privoxy.git diff --git a/actions.c b/actions.c index 2fb546f4..4257acc1 100644 --- a/actions.c +++ b/actions.c @@ -1,4 +1,4 @@ -const char actions_rcs[] = "$Id: actions.c,v 1.43 2008/03/01 14:00:43 fabiankeil Exp $"; +const char actions_rcs[] = "$Id: actions.c,v 1.45 2008/03/24 11:21:02 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/actions.c,v $ @@ -33,6 +33,15 @@ const char actions_rcs[] = "$Id: actions.c,v 1.43 2008/03/01 14:00:43 fabiankeil * * Revisions : * $Log: actions.c,v $ + * Revision 1.45 2008/03/24 11:21:02 fabiankeil + * Share the action settings for multiple patterns in the same + * section so we waste less memory for gigantic block lists + * (and load them slightly faster). Reported by Franz Schwartau. + * + * Revision 1.44 2008/03/04 18:30:34 fabiankeil + * Remove the treat-forbidden-connects-like-blocks action. We now + * use the "blocked" page for forbidden CONNECT requests by default. + * * Revision 1.43 2008/03/01 14:00:43 fabiankeil * Let the block action take the reason for the block * as argument and show it on the "blocked" page. @@ -462,6 +471,24 @@ jb_err copy_action (struct action_spec *dest, return err; } +/********************************************************************* + * + * Function : free_action_spec + * + * Description : Frees an action_spec and the memory used by it. + * + * Parameters : + * 1 : src = Source to free. + * + * Returns : N/A + * + *********************************************************************/ +void free_action_spec(struct action_spec *src) +{ + free_action(src); + freez(src); +} + /********************************************************************* * @@ -621,7 +648,8 @@ jb_err get_action_token(char **line, char **name, char **value) *********************************************************************/ static int action_used_to_be_valid(const char *action) { - return (0 == strcmpic(action, "treat-forbidden-connects-like-blocks")); + return (0 == strcmpic(action, "treat-forbidden-connects-like-blocks") + || 0 == strcmpic(action, "kill-popups")); } /********************************************************************* @@ -1119,11 +1147,19 @@ void unload_actions_file(void *file_data) { next = cur->next; free_url_spec(cur->url); - free_action(cur->action); + if ((next == NULL) || (next->action != cur->action)) + { + /* + * As the action settings might be shared, + * we can only free them if the current + * url pattern is the last one, or if the + * next one is using different settings. + */ + free_action_spec(cur->action); + } freez(cur); cur = next; } - } @@ -1388,8 +1424,7 @@ static int load_one_actions_file(struct client_state *csp, int fileid) { if (!cur_action_used) { - free_action(cur_action); - free(cur_action); + free_action_spec(cur_action); } cur_action = NULL; } @@ -1578,8 +1613,8 @@ static int load_one_actions_file(struct client_state *csp, int fileid) return 1; /* never get here */ } - /* Save flags */ - copy_action (perm->action, cur_action); + perm->action = cur_action; + cur_action_used = 1; /* Save the URL pattern */ if (create_url_spec(perm->url, buf)) @@ -1617,9 +1652,10 @@ static int load_one_actions_file(struct client_state *csp, int fileid) fclose(fp); - free_action(cur_action); - freez(cur_action); - + if (!cur_action_used) + { + free_action_spec(cur_action); + } free_alias_list(alias_list); /* the old one is now obsolete */