summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2005-05-24 14:01:16 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2005-05-24 14:01:16 +0000
commit056effc9457aa103c4833d5196d97f7232cd392c (patch)
treedb9a54c8bc58f953496de2f9baf703c8cfa1d11f
parent413504630308b58b8510651ddb4f564fb1e52ea3 (diff)
Uses indices instead of pointers
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6517 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/logf.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/firmware/logf.c b/firmware/logf.c
index 2cb5383783..a66709b939 100644
--- a/firmware/logf.c
+++ b/firmware/logf.c
@@ -34,27 +34,28 @@
#define MAX_LOGF_LINES 1000
#define MAX_LOGF_DATASIZE (16*MAX_LOGF_LINES)
-unsigned char logfbuffer[MAX_LOGF_DATASIZE];
-unsigned char *logfend=&logfbuffer[MAX_LOGF_DATASIZE];
-unsigned char *logfptr=&logfbuffer[0];
+unsigned char logfbuffer[MAX_LOGF_LINES][16];
+int logfindex;
bool logfwrap;
void logf(const char *format, ...)
{
int len;
+ unsigned char *ptr;
va_list ap;
va_start(ap, format);
- if(logfptr >= logfend) {
+ if(logfindex >= MAX_LOGF_LINES) {
/* wrap */
logfwrap = true;
- logfptr = &logfbuffer[0];
+ logfindex = 0;
}
- len = vsnprintf(logfptr, 16, format, ap);
+ ptr = logfbuffer[logfindex];
+ len = vsnprintf(ptr, 16, format, ap);
va_end(ap);
if(len < 16)
/* pad with spaces up to the 16 byte border */
- memset(logfptr+len, ' ', 16-len);
+ memset(ptr+len, ' ', 16-len);
- logfptr += 16; /* leave it where we write the next time */
+ logfindex++; /* leave it where we write the next time */
}