unsigned char array

Dependents:   MGC3130 SmartLabXBeeCore

Files at this revision

API Documentation at this revision

Comitter:
yangcq88517
Date:
Thu Nov 12 02:06:49 2015 +0000
Parent:
0:b35da77c40ca
Child:
2:765da30c4d9b
Commit message:
bug fix;

Changed in this revision

BufferedArray.cpp Show annotated file Show diff for this revision Revisions of this file
BufferedArray.h Show annotated file Show diff for this revision Revisions of this file
--- a/BufferedArray.cpp	Wed Nov 11 18:33:41 2015 +0000
+++ b/BufferedArray.cpp	Thu Nov 12 02:06:49 2015 +0000
@@ -87,7 +87,7 @@
         return;
 
     if (position >= max)
-        expandSpace(1);
+        expandSpace(position - max + 1);
 
     data[position] = value;
 }
@@ -98,16 +98,16 @@
     index++;
 }
 
-void BufferedArray::sets(const void * value, int length)
+void BufferedArray::sets(const unsigned char * value, int offset, int length)
 {
     if (length <= 0)
         return;
 
-    sets(index, value, length);
+    sets(index, value, offset, length);
     index += length;
 }
 
-void BufferedArray::sets(int position, const void * value, int length)
+void BufferedArray::sets(int position, const unsigned char * value, int offset, int length)
 {
     if (position < 0)
         return;
@@ -118,5 +118,5 @@
     if (position + length > max)
         expandSpace(position + length - max);
 
-    memcpy(data + index, value, length);
+    memcpy(data + position, value, length);
 }
\ No newline at end of file
--- a/BufferedArray.h	Wed Nov 11 18:33:41 2015 +0000
+++ b/BufferedArray.h	Thu Nov 12 02:06:49 2015 +0000
@@ -81,7 +81,7 @@
     * @param offset start point of the data
     * @param length length to write
     */
-    void sets(const void * value, int length);
+    void sets(const unsigned char * value, int offset, int length);
 
     /** Write 8-bit data into specific posiston and deos not affect the current position.
     * @param position where to write
@@ -95,7 +95,7 @@
     * @param offset start point of the data
     * @param length length to write
     */
-    void sets(int position, const void * value, int length);
+    void sets(int position, const unsigned char * value, int offset, int length);
 };
 
 #endif