changeset 1089:27d041472c8f

Cleanup, rename some variables, etc.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 02 Mar 2015 20:25:44 +0200
parents 9f06f6661cdf
children e0fb6fa1c689
files src/dmbstr.c src/dmbstr.h
diffstat 2 files changed, 17 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/dmbstr.c	Mon Mar 02 20:16:43 2015 +0200
+++ b/src/dmbstr.c	Mon Mar 02 20:25:44 2015 +0200
@@ -7,17 +7,17 @@
 #include "dmbstr.h"
 
 
-static int dmPutByteFILE(DMBitStreamContext *ctx, Uint8 val)
+static BOOL dmPutByteFILE(DMBitStreamContext *ctx, const Uint8 val)
 {
-    return fputc(val, (FILE *) ctx->fp);
+    return fputc(val, (FILE *) ctx->fp) == val;
 }
 
 
 void dmInitBitStreamContext(DMBitStreamContext *ctx)
 {
-    ctx->buf     = 0;
-    ctx->bytecnt = 0;
-    ctx->bitcnt  = 8;
+    ctx->outBuf       = 0;
+    ctx->outByteCount = 0;
+    ctx->outBitCount  = 8;
 }
 
 
@@ -42,21 +42,21 @@
 
     for (i = 0; i < n; i++)
     {
-        ctx->buf <<= 1;
+        ctx->outBuf <<= 1;
 
         if (val & mask)
-          ctx->buf |= 1;
+          ctx->outBuf |= 1;
 
         mask >>= 1;
-        ctx->bitcnt--;
+        ctx->outBitCount--;
 
-        if (ctx->bitcnt == 0)
+        if (ctx->outBitCount == 0)
         {
-            if (ctx->putByte(ctx, (ctx->buf & 0xff)) == EOF)
+            if (!ctx->putByte(ctx, ctx->outBuf & 0xff))
                 return FALSE;
 
-            ctx->bitcnt = 8;
-            ctx->bytecnt++;
+            ctx->outBitCount = 8;
+            ctx->outByteCount++;
         }
     }
 
@@ -69,8 +69,8 @@
   if (ctx == NULL)
       return DMERR_NULLPTR;
 
-  if (ctx->bitcnt != 8)
-      dmPutBits(ctx, 0, ctx->bitcnt);
+  if (ctx->outBitCount != 8)
+      dmPutBits(ctx, 0, ctx->outBitCount);
   
   return 0;
 }
--- a/src/dmbstr.h	Mon Mar 02 20:16:43 2015 +0200
+++ b/src/dmbstr.h	Mon Mar 02 20:25:44 2015 +0200
@@ -17,10 +17,10 @@
 
 typedef struct _DMBitStreamContext
 {
-  void *fp;
-  int (*putByte)(struct _DMBitStreamContext *ctx, Uint8 val);
+    void *fp;
+    BOOL (*putByte)(struct _DMBitStreamContext *ctx, Uint8 val);
 
-  int buf, bitcnt, bytecnt;
+    int outBuf, outBitCount, outByteCount;
 } DMBitStreamContext;