瀏覽代碼

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

master
kevin 11 年之前
父節點
當前提交
6f04687939
共有 1 個檔案被更改,包括 2 行新增2 行删除
  1. 2
    2
      cmArray.c

+ 2
- 2
cmArray.c 查看文件

@@ -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…
取消
儲存