[535] in BarnOwl Developers
[D-O-H] r654 - trunk/owl
daemon@ATHENA.MIT.EDU (asedeno@MIT.EDU)
Thu Oct 29 18:07:10 2009
Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: asedeno@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Mon, 5 Mar 2007 21:00:25 -0500 (EST)
Author: asedeno
Date: 2007-03-05 21:00:24 -0500 (Mon, 05 Mar 2007)
New Revision: 654
Modified:
trunk/owl/perlwrap.pm
trunk/owl/zephyr.c
Log:
perlwrap.pm: getting rid of one more mainloop_hook error message.
zephyr.c: reworking zephyr subscription process (again).
* Sub all at once if possible.
* Don't sub to zpunt lines.
Modified: trunk/owl/perlwrap.pm
===================================================================
--- trunk/owl/perlwrap.pm 2007-03-05 05:21:38 UTC (rev 653)
+++ trunk/owl/perlwrap.pm 2007-03-06 02:00:24 UTC (rev 654)
@@ -501,7 +501,7 @@
# use $shutdown to tell modules that that's what we're doing.
$BarnOwl::shutdown = 1;
- BarnOwl::mainloop_hook();
+ BarnOwl::mainloop_hook() if *BarnOwl::mainloop_hook{CODE};
BarnOwl::shutdown() if *BarnOwl::shutdown{CODE};
}
Modified: trunk/owl/zephyr.c
===================================================================
--- trunk/owl/zephyr.c 2007-03-05 05:21:38 UTC (rev 653)
+++ trunk/owl/zephyr.c 2007-03-06 02:00:24 UTC (rev 654)
@@ -87,6 +87,7 @@
owl_free(subs[i].zsub_classinst);
owl_free(subs[i].zsub_recipient);
}
+
return ret;
}
#endif
@@ -105,10 +106,12 @@
FILE *file;
char *tmp, *start;
char buffer[1024], subsfile[1024];
- ZSubscription_t subs[3001];
+ ZSubscription_t *subs;
+ int subSize = 1024;
int count, ret;
struct stat statbuff;
+ subs = owl_malloc(sizeof(ZSubscription_t) * subSize);
if (filename==NULL) {
sprintf(subsfile, "%s/%s", owl_global_get_homedir(&g), ".zephyr.subs");
} else {
@@ -134,13 +137,22 @@
start=buffer;
}
- if (count >= 3000) {
- ret = owl_zephyr_loadsubs_helper(subs, count);
- if (ret != 0) {
- fclose(file);
- return(ret);
+ if (count >= subSize) {
+ ZSubscription_t* newsubs;
+ newsubs = owl_realloc(subs, sizeof(ZSubscription_t) * subSize * 2);
+ if (NULL == newsubs) {
+ /* If realloc fails, load what we've got, clear, and continue */
+ ret = owl_zephyr_loadsubs_helper(subs, count);
+ if (ret != 0) {
+ fclose(file);
+ return(ret);
+ }
+ count=0;
}
- count=0;
+ else {
+ subs = newsubs;
+ subSize *= 2;
+ }
}
/* add it to the list of subs */
@@ -151,17 +163,22 @@
if ((tmp=(char *) strtok(NULL, " \t\n\r"))==NULL) continue;
subs[count].zsub_recipient=owl_strdup(tmp);
- /* if it started with '-' then add it to the global punt list */
+ /* if it started with '-' then add it to the global punt list, and
+ * remove it from the list of subs. */
if (buffer[0]=='-') {
owl_function_zpunt(subs[count].zsub_class, subs[count].zsub_classinst, subs[count].zsub_recipient, 0);
+ owl_free(subs[count].zsub_class);
+ owl_free(subs[count].zsub_classinst);
+ owl_free(subs[count].zsub_recipient);
}
-
- count++;
+ else {
+ count++;
+ }
}
fclose(file);
ret=owl_zephyr_loadsubs_helper(subs, count);
-
+ owl_free(subs);
return(ret);
#else
return(0);