ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

ff_hash.c
Go to the documentation of this file.
00001 /*****************************************************************************
00002  *  FullFAT - High Performance, Thread-Safe Embedded FAT File-System         *
00003  *  Copyright (C) 2009  James Walmsley (james@worm.me.uk)                    *
00004  *                                                                           *
00005  *  This program is free software: you can redistribute it and/or modify     *
00006  *  it under the terms of the GNU General Public License as published by     *
00007  *  the Free Software Foundation, either version 3 of the License, or        *
00008  *  (at your option) any later version.                                      *
00009  *                                                                           *
00010  *  This program is distributed in the hope that it will be useful,          *
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00013  *  GNU General Public License for more details.                             *
00014  *                                                                           *
00015  *  You should have received a copy of the GNU General Public License        *
00016  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.    *
00017  *                                                                           *
00018  *  IMPORTANT NOTICE:                                                        *
00019  *  =================                                                        *
00020  *  Alternative Licensing is available directly from the Copyright holder,   *
00021  *  (James Walmsley). For more information consult LICENSING.TXT to obtain   *
00022  *  a Commercial license.                                                    *
00023  *                                                                           *
00024  *  See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT.       *
00025  *                                                                           *
00026  *  Removing the above notice is illegal and will invalidate this license.   *
00027  *****************************************************************************
00028  *  See http://worm.me.uk/fullfat for more information.                      *
00029  *  Or  http://fullfat.googlecode.com/ for latest releases and the wiki.     *
00030  *****************************************************************************/
00031 
00042 #include "ff_hash.h"
00043 #include <stdlib.h>
00044 #include <string.h>
00045 
00046 #ifdef FF_HASH_CACHE
00047 struct _FF_HASH_TABLE {
00048     FF_T_UINT8 bitTable[FF_HASH_TABLE_SIZE];
00049 };
00050 
00055 FF_HASH_TABLE FF_CreateHashTable() {
00056     FF_HASH_TABLE pHash = (FF_HASH_TABLE) FF_MALLOC(sizeof(struct _FF_HASH_TABLE));
00057 
00058     if(pHash) {
00059         FF_ClearHashTable(pHash);
00060         return pHash;
00061     }
00062 
00063     return NULL;
00064 }
00065 
00066 FF_ERROR FF_ClearHashTable(FF_HASH_TABLE pHash) {
00067     if(pHash) {
00068         memset(pHash->bitTable, 0, FF_HASH_TABLE_SIZE);
00069         return FF_ERR_NONE;
00070     }
00071 
00072     return FF_ERR_NULL_POINTER;
00073 }
00074 
00075 FF_ERROR FF_SetHash(FF_HASH_TABLE pHash, FF_T_UINT32 nHash) {
00076     FF_T_UINT32 tblIndex    = ((nHash / 8) % FF_HASH_TABLE_SIZE);
00077     FF_T_UINT32 tblBit      = nHash % 8;
00078 
00079     if(pHash) {
00080         pHash->bitTable[tblIndex] |= (0x80 >> tblBit);
00081         return FF_ERR_NONE;
00082     }
00083 
00084     return FF_ERR_NULL_POINTER; 
00085 }
00086 
00087 FF_ERROR FF_ClearHash(FF_HASH_TABLE pHash, FF_T_UINT32 nHash) {
00088     FF_T_UINT32 tblIndex    = ((nHash / 8) % FF_HASH_TABLE_SIZE);
00089     FF_T_UINT32 tblBit      = nHash % 8;
00090 
00091     if(pHash) {
00092         pHash->bitTable[tblIndex] &= ~(0x80 >> tblBit);
00093         return FF_ERR_NONE;
00094     }
00095 
00096     return FF_ERR_NULL_POINTER;
00097 }
00098 
00099 FF_T_BOOL FF_isHashSet(FF_HASH_TABLE pHash, FF_T_UINT32 nHash) {
00100     FF_T_UINT32 tblIndex    = ((nHash / 8) % FF_HASH_TABLE_SIZE);
00101     FF_T_UINT32 tblBit      = nHash % 8;
00102 
00103     if(pHash) {
00104         if(pHash->bitTable[tblIndex] & (0x80 >> tblBit)) {
00105             return FF_TRUE;
00106         }
00107     }
00108     return FF_FALSE;
00109 }
00110 
00111 FF_ERROR FF_DestroyHashTable(FF_HASH_TABLE pHash) {
00112     if(pHash) {
00113         FF_FREE(pHash);
00114         return FF_ERR_NONE;
00115     }
00116     return FF_ERR_NULL_POINTER;
00117 }
00118 
00119 #endif

Generated on Sun May 27 2012 04:34:08 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.