Changeset 511 for trunk/psLib/src/collections/psBitMask.c
- Timestamp:
- Apr 23, 2004, 11:33:59 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/collections/psBitMask.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psBitMask.c
r438 r511 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-04- 17 02:43:59 $11 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-04-23 21:33:59 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 24 24 25 25 #include "psBitMask.h" 26 //#include "psMemory.h"26 #include "psMemory.h" 27 27 28 28 /*****************************************************************************/ … … 35 35 index = bit/8; 36 36 byte = inMask->bits+index; 37 37 38 38 return byte; 39 39 } … … 43 43 char mask = 0x01; 44 44 mask = mask << (bit%8); 45 45 46 46 return mask; 47 47 } … … 52 52 psBitMask* psBitMaskAlloc(int n) 53 53 { 54 // psBitMask *newObj = (psBitMask*)psAlloc(sizeof(psBitMask)); 55 psBitMask *newObj = (psBitMask*)malloc(sizeof(psBitMask)); 54 psBitMask *newObj = psAlloc(sizeof(psBitMask)); 56 55 newObj->n = n; 57 newObj->bits = (char*)malloc(sizeof(char)*n);56 newObj->bits = psAlloc(sizeof(char)*n); 58 57 memset(newObj->bits, n, 0); 59 58 60 59 return newObj; 61 60 } … … 71 70 char* byte = getByte(bit, inMask); 72 71 *byte |= mask(bit); 73 72 74 73 return inMask; 75 74 } … … 81 80 return 0; 82 81 } 83 82 84 83 return 1; 85 84 } 86 85 87 psBitMask* psBitMaskOp(psBitMask *outMask, const psBitMask *restrict inMask1, char *operator, 86 psBitMask* psBitMaskOp(psBitMask *outMask, const psBitMask *restrict inMask1, char *operator, 88 87 const psBitMask *restrict inMask2) 89 88 { … … 99 98 return outMask; 100 99 } 101 100 102 101 if(inMask1 == NULL) { 103 102 printf("Null input psBitMask1\n"); 104 103 return outMask; 105 104 } 106 105 107 106 if(operator == NULL) { 108 107 printf("Null input operator\n"); … … 110 109 111 110 } 112 111 113 112 if(inMask2 == NULL) { 114 113 printf("Null input psBitMask2\n"); 115 114 return outMask; 116 115 } 117 116 118 117 if(inMask1->n != inMask2->n || outMask->n != inMask1->n) { 119 118 printf("Mask sizes not the same\n"); 120 119 return outMask; 121 120 } 122 121 123 122 n = outMask->n; 124 123 outBits = outMask->bits; 125 124 inBits1 = inMask1->bits; 126 125 inBits2 = inMask2->bits; 127 126 128 127 tempChar = toupper(*operator); 129 128 switch(tempChar) { … … 146 145 printf("Invalid psBitMask option %s\n", operator); 147 146 } 148 147 149 148 return outMask; 150 149 } … … 158 157 outString[numBits-i-1] = (psBitMaskTest(inMask, i))?'1':'0'; 159 158 } 160 159 161 160 return outString; 162 161 }
Note:
See TracChangeset
for help on using the changeset viewer.
