X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=apps%2Firssi%2Fsrc%2Fcore%2Fline-split.c;fp=apps%2Firssi%2Fsrc%2Fcore%2Fline-split.c;h=0ee87d2309400b35a9c868ea223127d161d29591;hb=18d69a0a1fec438e241bb4f431506ed59a34066b;hp=a1e96544adba037da20f50f0b8716bd5906a972e;hpb=f7be6adec0248118cddde9b04522c13cd90568cd;p=silc.git diff --git a/apps/irssi/src/core/line-split.c b/apps/irssi/src/core/line-split.c index a1e96544..0ee87d23 100644 --- a/apps/irssi/src/core/line-split.c +++ b/apps/irssi/src/core/line-split.c @@ -13,9 +13,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "module.h" @@ -43,8 +43,7 @@ static void linebuf_append(LINEBUF_REC *rec, const char *data, int len) { if (rec->len+len > rec->alloc) { rec->alloc = nearest_power(rec->len+len);; - rec->str = rec->str == NULL ? g_malloc(rec->alloc) : - g_realloc(rec->str, rec->alloc); + rec->str = g_realloc(rec->str, rec->alloc); } memcpy(rec->str + rec->len, data, len); @@ -53,12 +52,7 @@ static void linebuf_append(LINEBUF_REC *rec, const char *data, int len) static char *linebuf_find(LINEBUF_REC *rec, char chr) { - int n; - - for (n = 0; n < rec->len; n++) - if (rec->str[n] == chr) return rec->str+n; - - return NULL; + return memchr(rec->str, chr, rec->len); } static int remove_newline(LINEBUF_REC *rec) @@ -114,7 +108,6 @@ int line_split(const char *data, int len, char **output, LINEBUF_REC **buffer) return -1; /* no new data got but still something in buffer.. */ - len = 0; if (linebuf_find(rec, '\n') == NULL) { /* connection closed and last line is missing \n .. just add it so we can see if it had