CoreFW  Diff

Differences From Artifact [8f48f16d9c]:

To Artifact [58791b4765]:


21
22
23
24
25
26
27

28
29
30
31
32
33
34
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35







+







 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include <stdlib.h>
#include <stdint.h>

#include "cfwobject.h"
#include "cfwarray.h"

struct CFWArray {
	CFWObject obj;
	void **data;
198
199
200
201
202
203
204
















































205
206
207
208
209
210
211
212
213
214
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+










	cfw_unref(last);

	array->data = new;
	array->size--;

	return true;
}

bool
cfw_array_contains(CFWArray *array, void *ptr)
{
	size_t i;

	for (i = 0; i < array->size; i++)
		if (cfw_equal(array->data[i], ptr))
			return true;

	return false;
}

bool
cfw_array_contains_ptr(CFWArray *array, void *ptr)
{
	size_t i;

	for (i = 0; i < array->size; i++)
		if (array->data[i] == ptr)
			return true;

	return false;
}

size_t
cfw_array_find(CFWArray *array, void *ptr)
{
	size_t i;

	for (i = 0; i < array->size; i++)
		if (cfw_equal(array->data[i], ptr))
			return i;

	return SIZE_MAX;
}

size_t
cfw_array_find_ptr(CFWArray *array, void *ptr)
{
	size_t i;

	for (i = 0; i < array->size; i++)
		if (array->data[i] == ptr)
			return i;

	return SIZE_MAX;
}

static CFWClass class = {
	.name = "CFWArray",
	.size = sizeof(CFWArray),
	.ctor = ctor,
	.dtor = dtor,
	.equal = equal,
	.copy = copy
};
CFWClass *cfw_array = &class;