current client-tags.c,1.8,1.9
Fabian Keil <[email protected]> Mon, 20 Feb 2017 13:48:56 +0000
| Newsgroups | gmane.comp.web.privoxy.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/ijbswa/current
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv15510
Modified Files:
client-tags.c
Log Message:
Factor create_client_specific_tag() out of add_tag_for_client()
... to reduce code duplication and make bugs like the one
fixed in r1.8 less likely.
Index: client-tags.c
===================================================================
RCS file: /cvsroot/ijbswa/current/client-tags.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** client-tags.c 20 Feb 2017 13:47:51 -0000 1.8
--- client-tags.c 20 Feb 2017 13:48:54 -0000 1.9
***************
*** 301,304 ****
--- 301,333 ----
}
+
+ /*********************************************************************
+ *
+ * Function : create_client_specific_tag
+ *
+ * Description : Allocates memory for a client specific tag
+ * and populates it.
+ *
+ * Parameters :
+ * 1 : name = The name of the tag to create.
+ * 2 : time_to_live = 0, or the number of seconds
+ * the tag remains activated.
+ *
+ * Returns : Pointer to populated tag
+ *
+ *********************************************************************/
+ static struct client_specific_tag *create_client_specific_tag(const char *name,
+ const time_t time_to_live)
+ {
+ struct client_specific_tag *tag;
+
+ tag = zalloc_or_die(sizeof(struct client_specific_tag));
+ tag->name = strdup_or_die(name);
+ tag->end_of_life = time_to_live ? (time(NULL) + time_to_live) : 0;
+
+ return tag;
+
+ }
+
/*********************************************************************
*
***************
*** 329,336 ****
requested_tags = zalloc_or_die(sizeof(struct requested_tags));
requested_tags->client = strdup_or_die(client_address);
! requested_tags->tags = zalloc_or_die(sizeof(struct client_specific_tag));
! requested_tags->tags->name = strdup_or_die(tag);
! requested_tags->tags->end_of_life = time_to_live ?
! (time(NULL) + time_to_live) : 0;
validate_requested_tags();
--- 358,362 ----
requested_tags = zalloc_or_die(sizeof(struct requested_tags));
requested_tags->client = strdup_or_die(client_address);
! requested_tags->tags = create_client_specific_tag(tag, time_to_live);
validate_requested_tags();
***************
*** 355,362 ****
clients_with_tags = clients_with_tags->next;
clients_with_tags->client = strdup_or_die(client_address);
! clients_with_tags->tags = zalloc_or_die(sizeof(struct client_specific_tag));
! clients_with_tags->tags->name = strdup_or_die(tag);
! clients_with_tags->tags->end_of_life = time_to_live ?
! (time(NULL) + time_to_live) : 0;
validate_requested_tags();
--- 381,385 ----
clients_with_tags = clients_with_tags->next;
clients_with_tags->client = strdup_or_die(client_address);
! clients_with_tags->tags = create_client_specific_tag(tag, time_to_live);
validate_requested_tags();
***************
*** 371,378 ****
if (enabled_tags->next == NULL)
{
! enabled_tags->next = zalloc_or_die(sizeof(struct client_specific_tag));
! enabled_tags->next->name = strdup_or_die(tag);
! enabled_tags->next->end_of_life = time_to_live ?
! (time(NULL) + time_to_live) : 0;
enabled_tags->next->prev = enabled_tags;
break;
--- 394,398 ----
if (enabled_tags->next == NULL)
{
! enabled_tags->next = create_client_specific_tag(tag, time_to_live);
enabled_tags->next->prev = enabled_tags;
break;
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot