gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r7377 - GNUnet/src/util/error


From: gnunet
Subject: [GNUnet-SVN] r7377 - GNUnet/src/util/error
Date: Wed, 2 Jul 2008 11:50:08 -0600 (MDT)

Author: amatus
Date: 2008-07-02 11:50:07 -0600 (Wed, 02 Jul 2008)
New Revision: 7377

Modified:
   GNUnet/src/util/error/error.c
Log:
Remove non-posix strnlen.


Modified: GNUnet/src/util/error/error.c
===================================================================
--- GNUnet/src/util/error/error.c       2008-07-02 07:35:48 UTC (rev 7376)
+++ GNUnet/src/util/error/error.c       2008-07-02 17:50:07 UTC (rev 7377)
@@ -131,16 +131,22 @@
   char msg[DATE_STR_SIZE + BULK_TRACK_SIZE + 256];
   GNUNET_CronTime now;
   int rev;
+  char *last;
 
   if ( (ctx->last_bulk_time == 0) ||
        (ctx->last_bulk_repeat == 0) )
     return;
   now = GNUNET_get_time();
   rev = 0;
-  if (ctx->last_bulk[strnlen(ctx->last_bulk, BULK_TRACK_SIZE)-1] == '\n') 
+  last = memchr(ctx->last_bulk, '\0', BULK_TRACK_SIZE);
+  if(last == NULL)
+    last = &ctx->last_bulk[BULK_TRACK_SIZE-1];
+  else if(last != ctx->last_bulk)
+    last--;
+  if (last[0] == '\n') 
     {
       rev = 1;
-      ctx->last_bulk[strnlen(ctx->last_bulk, BULK_TRACK_SIZE)-1] = '\0';
+      last[0] = '\0';
     }
   snprintf(msg,
           sizeof(msg),
@@ -150,7 +156,7 @@
           ctx->last_bulk_repeat,
           (now - ctx->last_bulk_time) / GNUNET_CRON_SECONDS);
   if (rev == 1)
-    ctx->last_bulk[strnlen(ctx->last_bulk, BULK_TRACK_SIZE-1)] = '\n';
+    last[0] = '\n';
   if (ctx != NULL)
     ctx->handler (ctx->cls, ctx->last_bulk_kind, datestr, msg);
   else





reply via email to

[Prev in Thread] Current Thread [Next in Thread]