changeset 92:8dc22f80d193

Use vmalloc for large memory allocations
author charles <charles>
date Sun, 09 Oct 2005 07:55:00 +0000
parents 07a42c94dda5
children 05d7dee4c19b
files yaffs_guts.c yaffs_guts.h
diffstat 2 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/yaffs_guts.c
+++ b/yaffs_guts.c
@@ -13,7 +13,7 @@
  */
 
 const char *yaffs_guts_c_version =
-    "$Id: yaffs_guts.c,v 1.20 2005-10-07 02:46:49 charles Exp $";
+    "$Id: yaffs_guts.c,v 1.21 2005-10-09 07:55:00 charles Exp $";
 
 #include "yportenv.h"
 
@@ -1757,6 +1757,13 @@ static int yaffs_InitialiseBlocks(yaffs_
 	/* Set up dynamic blockinfo stuff. */
 	dev->chunkBitmapStride = (dev->nChunksPerBlock + 7) / 8;
 	dev->chunkBits = YMALLOC(dev->chunkBitmapStride * nBlocks);
+	if(!dev->chunkBits){
+		dev->chunkBits = YMALLOC_ALT(dev->chunkBitmapStride * nBlocks);
+		dev->chunkBitsAlt = 1;
+	}
+	else
+		dev->chunkBitsAlt = 0;
+	
 	if (dev->blockInfo && dev->chunkBits) {
 		memset(dev->blockInfo, 0, nBlocks * sizeof(yaffs_BlockInfo));
 		memset(dev->chunkBits, 0, dev->chunkBitmapStride * nBlocks);
@@ -1776,7 +1783,12 @@ static void yaffs_DeinitialiseBlocks(yaf
 	dev->blockInfoAlt = 0;
 
 	dev->blockInfo = NULL;
-	YFREE(dev->chunkBits);
+	
+	if(dev->chunkBitsAlt)
+		YFREE_ALT(dev->chunkBits);
+	else
+		YFREE(dev->chunkBits);
+	dev->chunkBitsAlt = 0;
 	dev->chunkBits = NULL;
 }
 
--- a/yaffs_guts.h
+++ b/yaffs_guts.h
@@ -14,7 +14,7 @@
  *
  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  *
- * $Id: yaffs_guts.h,v 1.15 2005-10-07 02:46:50 charles Exp $
+ * $Id: yaffs_guts.h,v 1.16 2005-10-09 07:55:00 charles Exp $
  */
 
 #ifndef __YAFFS_GUTS_H__
@@ -561,8 +561,9 @@ struct yaffs_DeviceStruct {
 
 	/* Block Info */
 	yaffs_BlockInfo *blockInfo;
-	int blockInfoAlt;	/* was allocated using alternative strategy */
 	__u8 *chunkBits;	/* bitmap of chunks in use */
+	unsigned blockInfoAlt:1;	/* was allocated using alternative strategy */
+	unsigned chunkBitsAlt:1;	/* was allocated using alternative strategy */
 	int chunkBitmapStride;	/* Number of bytes of chunkBits per block. 
 				 * Must be consistent with nChunksPerBlock.
 				 */