Browse Source

cmArray.c: Fixed bug cmArrayAlloc0() where p->alloc_cnt was treated as byte count instead of element count.

master
kevin 11 years ago
parent
commit
6f04687939
1 changed files with 2 additions and 2 deletions
  1. 2
    2
      cmArray.c

+ 2
- 2
cmArray.c View File

@@ -44,13 +44,13 @@ cmArRC_t    cmArrayAlloc0(  cmCtx_t* ctx, cmArrayH_t* hp, unsigned eleByteCnt, u
44 44
   cmAr_t* p = cmMemAllocZ(cmAr_t,1);
45 45
   cmErrSetup(&p->err,&ctx->rpt,"Array");
46 46
 
47
-  p->alloc_cnt    = initCnt * eleByteCnt;
47
+  p->alloc_cnt    = initCnt;
48 48
   p->expand_cnt   = expandCnt;
49 49
   p->cur_cnt      = 0;
50 50
   p->ele_byte_cnt = eleByteCnt;
51 51
 
52 52
   if( p->alloc_cnt > 0 )
53
-    p->base = cmMemAllocZ(char,p->alloc_cnt);
53
+    p->base = cmMemAllocZ(char,p->alloc_cnt*eleByteCnt);
54 54
 
55 55
   hp->h = p;
56 56
   

Loading…
Cancel
Save