ithewei 6 éve
szülő
commit
d77d7fd7da
5 módosított fájl, 27 hozzáadás és 29 törlés
  1. 9 9
      hbuf.h
  2. 4 16
      hdef.h
  3. 1 1
      hfile.h
  4. 2 2
      hframe.h
  5. 11 1
      hplatform.h

+ 9 - 9
hbuf.h

@@ -8,7 +8,7 @@
 #include "hdef.h"
 
 typedef struct hbuf_s {
-    uint8* base;
+    uint8_t* base;
     size_t len;
 
 #ifdef __cplusplus
@@ -18,7 +18,7 @@ typedef struct hbuf_s {
     }
 
     hbuf_s(void* data, size_t len) {
-        this->base = (uint8*)data;
+        this->base = (uint8_t*)data;
         this->len  = len;
     }
 #endif
@@ -60,11 +60,11 @@ public:
         if (cap == len) return;
 
         if (base == NULL) {
-            base = (uint8*)malloc(cap);
+            base = (uint8_t*)malloc(cap);
             memset(base, 0, cap);
         }
         else {
-            base = (uint8*)realloc(base, cap);
+            base = (uint8_t*)realloc(base, cap);
         }
         len = cap;
         cleanup_ = true;
@@ -91,13 +91,13 @@ public:
     HVLBuf(size_t cap) : HBuf(cap) {_offset = _size = 0;}
     virtual ~HVLBuf() {}
 
-    uint8* data() { return base+_offset; }
+    uint8_t* data() { return base+_offset; }
     size_t size() { return _size; }
 
     void push_front(void* ptr, size_t len) {
         if (len > this->len - _size) {
             this->len = MAX(this->len, len)*2;
-            base = (uint8*)realloc(base, this->len);
+            base = (uint8_t*)realloc(base, this->len);
         }
 
         if (_offset < len) {
@@ -114,7 +114,7 @@ public:
     void push_back(void* ptr, size_t len) {
         if (len > this->len - _size) {
             this->len = MAX(this->len, len)*2;
-            base = (uint8*)realloc(base, this->len);
+            base = (uint8_t*)realloc(base, this->len);
         }
         else if (len > this->len - _offset - _size) {
             // move => start
@@ -176,8 +176,8 @@ public:
     HRingBuf(size_t cap) : HBuf(cap) {_head = _tail = _size = 0;}
     virtual ~HRingBuf() {}
 
-    uint8* alloc(size_t len) {
-        uint8* ret = NULL;
+    uint8_t* alloc(size_t len) {
+        uint8_t* ret = NULL;
         if (_head < _tail || _size == 0) {
             // [_tail, this->len) && [0, _head)
             if (this->len - _tail >= len) {

+ 4 - 16
hdef.h

@@ -3,22 +3,6 @@
 
 #include "hplatform.h"
 
-typedef unsigned char       uint8;
-typedef unsigned short      uint16;
-typedef unsigned int        uint32;
-
-typedef char                int8;
-typedef short               int16;
-typedef int                 int32;
-
-#ifdef _MSC_VER
-typedef __int64             int64;
-typedef unsigned __int64    uint64;
-#else
-typedef int64_t             int64;
-typedef uint64_t            uint64;
-#endif
-
 typedef float               float32;
 typedef double              float64;
 
@@ -94,6 +78,10 @@ typedef std::map<std::string, std::string> keyval_t;
 #define TRUE                1
 #endif
 
+#ifndef INFINITE
+#define INFINITE            0xFFFFFFFF
+#endif
+
 #ifndef CR
 #define CR      '\r'
 #endif

+ 1 - 1
hfile.h

@@ -14,7 +14,7 @@
 #include "herr.h"
 
 class HFile {
- public:
+public:
     HFile() {
         _fp = NULL;
     }

+ 2 - 2
hframe.h

@@ -13,8 +13,8 @@ public:
     int h;
     int bpp;
     int type;
-    uint64 ts;
-    int64 useridx;
+    uint64_t ts;
+    int64_t useridx;
     void* userdata;
 
     HFrame() {

+ 11 - 1
hplatform.h

@@ -139,8 +139,18 @@
 #include <signal.h>
 
 // c99
-#include <stdbool.h>
+#if defined(_MSC_VER) && _MSC_VER < 1700
+typedef __int8      int8_t;
+typedef __int16     int16_t;
+typedef __int32     int32_t;
+typedef __int64     int64_t;
+typedef unsigned __int8     uint8_t;
+typedef unsigned __int16    uint16_t;
+typedef unsigned __int32    uint32_t;
+typedef unsigned __int64    uint64_t;
+#else
 #include <stdint.h>
+#endif
 
 // POSIX C
 #include <sys/types.h>