Bladeren bron

* Remove unused buffers from String::printf changes

Bryan Drewery 15 jaren geleden
bovenliggende
commit
e29898f1c7
8 gewijzigde bestanden met toevoegingen van 1 en 29 verwijderingen
  1. 0 1
      src/conf.c
  2. 0 2
      src/misc.c
  3. 1 14
      src/mod/channels.mod/userchan.c
  4. 0 1
      src/mod/console.mod/console.c
  5. 0 1
      src/mod/server.mod/server.c
  6. 0 2
      src/set.c
  7. 0 6
      src/userent.c
  8. 0 2
      src/userrec.c

+ 0 - 1
src/conf.c

@@ -694,7 +694,6 @@ writeconf(char *filename, int fd, int bits)
   int autowrote = 0;
 
   bd::Stream* stream;
-  bd::String buf;
 
   if (bits & CONF_ENC) {
     const char salt1[] = SALT1;

+ 0 - 2
src/misc.c

@@ -784,8 +784,6 @@ restart(int idx)
     if (socklist[fd].sock != STDOUT)
       sock_write(stream, fd);
 
-  bd::String buf;
-
   if (server_online) {
     if (botname[0])
       stream << bd::String::printf(STR("+botname %s\n"), botname);

+ 1 - 14
src/mod/channels.mod/userchan.c

@@ -572,7 +572,6 @@ static void tell_masks(const char type, int idx, bool show_inact, char *match, b
  */
 void write_bans(bd::Stream& stream, int idx)
 {
-  bd::String buf;
   if (global_ign)
     stream << bd::String::printf(IGNORE_NAME " - -\n");
 
@@ -624,8 +623,6 @@ void write_bans(bd::Stream& stream, int idx)
  */
 void write_exempts(bd::Stream& stream, int idx)
 {
-  bd::String buf;
-
   if (global_exempts)
     stream << bd::String::printf(EXEMPT_NAME " - -\n");
 
@@ -663,8 +660,6 @@ void write_exempts(bd::Stream& stream, int idx)
  */
 void write_invites(bd::Stream& stream, int idx)
 {
-  bd::String buf;
-
   if (global_invites)
     stream << bd::String::printf(INVITE_NAME " - -\n");
 
@@ -703,8 +698,6 @@ void write_invites(bd::Stream& stream, int idx)
  */
 static void write_chan(bd::Stream& stream, int idx, struct chanset_t* chan)
 {
-  bd::String buf;
-
   putlog(LOG_DEBUG, "*", "writing channel %s to userfile..", chan->dname);
 
   bool force_inactive = 0;
@@ -720,11 +713,10 @@ static void write_chan(bd::Stream& stream, int idx, struct chanset_t* chan)
 }
 
 bd::String channel_to_string(struct chanset_t* chan, bool force_inactive) {
-  bd::String buf;
   char w[1024] = "";
 
   get_mode_protect(chan, w, sizeof(w));
-  buf = bd::String::printf("\
+  return bd::String::printf("\
 chanmode { %s } bad-cookie %d manop %d mdop %d mop %d limit %d ban-type %d \
 flood-chan %d:%d flood-ctcp %d:%d flood-join %d:%d \
 flood-kick %d:%d flood-deop %d:%d flood-nick %d:%d flood-mjoin %d:%d \
@@ -799,15 +791,12 @@ flood-exempt %d flood-lock-time %d knock %d \
  *      PLSMNS(channel_temp(chan)),
  */
   );
-  return buf;
 }
 
 /* Write the channels to the userfile
  */
 void write_chans(bd::Stream& stream, int idx, bool old)
 {
-  bd::String buf;
-
   putlog(LOG_DEBUG, "*", "Writing channels..");
 
   stream << bd::String::printf(CHANS_NAME " - -\n");
@@ -824,8 +813,6 @@ void write_chans(bd::Stream& stream, int idx, bool old)
  */
 void write_chans_compat(bd::Stream& stream, int idx)
 {
-  bd::String buf;
-
   putlog(LOG_DEBUG, "*", "Writing channels..");
 
   stream << bd::String::printf(CHANS_NAME " - -\n");

+ 0 - 1
src/mod/console.mod/console.c

@@ -108,7 +108,6 @@ console_write_userfile(bd::Stream& stream, const struct userrec *u, const struct
     return;
 
   struct console_info *i = (struct console_info *) e->u.extra;
-  bd::String buf;
 
   stream << bd::String::printf("--CONSOLE %s %s %s %d %d %d %d %d %d %d %d\n",
                i->channel, masktype(i->conflags),

+ 0 - 1
src/mod/server.mod/server.c

@@ -510,7 +510,6 @@ void replay_cache(int idx, bd::Stream* stream) {
 
   for (r = cacheq.head; r; r = r->next) {
     if (stream) {
-      bd::String buf;
       *stream << bd::String::printf(STR("+serv_cache %s\n"), r->msg);
     } else {
       //Create temporary buffer since server_activity may squash the buffer

+ 0 - 2
src/set.c

@@ -871,8 +871,6 @@ static char *var_rem_list(const char *botnick, variable_t *var, const char *elem
 
 void write_vars_and_cmdpass(bd::Stream& stream, int idx)
 {
-  bd::String buf;
-
   putlog(LOG_DEBUG, "@", "Writing set entries...");
   stream << bd::String::printf(SET_NAME " - -\n");
 

+ 0 - 6
src/userent.c

@@ -99,14 +99,12 @@ void write_userfile_protected(bd::Stream& stream, const struct userrec *u, const
   int localhub = nextbot(u->handle);
   /* only write if saving local, or if sending to hub, or if sending to same user as entry, or the localhub in the chain */
   if (idx == -1 || dcc[idx].hub || dcc[idx].user == u || (localhub != -1 && idx == localhub)) {
-    bd::String buf;
     stream << bd::String::printf("--%s %s\n", e->type->name, e->u.string);
   }
 }
 
 void def_write_userfile(bd::Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
 {
-  bd::String buf;
   stream << bd::String::printf("--%s %s\n", e->type->name, e->u.string);
 }
 
@@ -370,7 +368,6 @@ static void set_write_userfile(bd::Stream& stream, const struct userrec *u, cons
   /* only write if saving local, or if sending to hub, or if sending to same user as entry, or the localhub in the chain */
   if (idx == -1 || dcc[idx].hub || dcc[idx].user == u || (localhub != -1 && idx == localhub)) {
     struct xtra_key *x = (struct xtra_key *) e->u.extra;
-    bd::String buf;
 
     for (; x; x = x->next)
       stream << bd::String::printf("--%s %s %s\n", e->type->name, x->key, x->data ? x->data : "");
@@ -706,7 +703,6 @@ static bool laston_unpack(struct userrec *u, struct user_entry *e)
 static void laston_write_userfile(bd::Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
 {
   struct laston_info *li = (struct laston_info *) e->u.extra;
-  bd::String buf;
 
   stream << bd::String::printf("--LASTON %li %s\n", (long) li->laston, li->lastonplace ? li->lastonplace : "");
 }
@@ -828,7 +824,6 @@ static bool botaddr_kill(struct user_entry *e)
 static void botaddr_write_userfile(bd::Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
 {
   register struct bot_addr *bi = (struct bot_addr *) e->u.extra;
-  bd::String buf;
 
   stream << bd::String::printf("--%s %s:%u/%u:%u:%s\n", e->type->name, bi->address, bi->telnet_port, bi->relay_port, bi->hublevel, bi->uplink);
 }
@@ -915,7 +910,6 @@ struct user_entry_type USERENTRY_BOTADDR =
 static void hosts_write_userfile(bd::Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
 {
   struct list_type *h = NULL;
-  bd::String buf;
 
   for (h = (struct list_type *) e->u.extra; h; h = h->next)
     stream << bd::String::printf("--HOSTS %s\n", h->extra);

+ 0 - 2
src/userrec.c

@@ -360,7 +360,6 @@ static void write_user(const struct userrec *u, bd::Stream& stream, int idx)
 {
   char s[181] = "";
   struct flag_record fr = {FR_GLOBAL, u->flags, 0, 0 };
-  bd::String buf;
 
   build_flags(s, &fr, NULL);
   stream << bd::String::printf("%s%s - %s\n", u->bot ? "-" : "", u->handle, s);
@@ -466,7 +465,6 @@ static void sort_userlist()
 void stream_writeuserfile(bd::Stream& stream, const struct userrec *bu, bool old) {
   time_t tt = now;
   char s1[81] = "";
-  bd::String buf;
 
   strcpy(s1, ctime(&tt));