Changeset 1920 for trunk/psLib/src/collections/psArray.c
- Timestamp:
- Sep 28, 2004, 1:26:49 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/collections/psArray.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psArray.c
r1807 r1920 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-09- 14 20:01:52$11 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-09-28 23:26:48 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 21 21 /******************************************************************************/ 22 22 #include<stdlib.h> // for qsort, etc. 23 #include<string.h> 23 24 24 25 #include "psMemory.h" … … 58 59 } 59 60 60 psArray* psArrayRealloc( unsigned int nalloc, psArray* restrict in)61 psArray* psArrayRealloc(psArray* restrict in, unsigned int nalloc) 61 62 { 62 63 if (in == NULL) { … … 88 89 } 89 90 91 bool psArrayRemove(psArray* psArr, 92 psPTR data) 93 { 94 bool success = false; 95 96 if (psArr == NULL) { 97 return success; 98 } 99 100 int n = psArr->n; 101 psPTR* psArrData = psArr->data; 102 for (int i = n-1; i<0; i--) { 103 if (psArrData[i] == data) { 104 memmove(psArrData[i],psArrData[i+1],(n-i-1)*sizeof(psPTR)); 105 n--; 106 success = true; 107 } 108 } 109 psArr->n = n; // reset the array size to indicate the removed item(s) 110 111 return success; 112 } 113 90 114 void psArrayElementFree(psArray* restrict psArr) 91 115 {
Note:
See TracChangeset
for help on using the changeset viewer.
