ObjFW  Diff

Differences From Artifact [3fd803b400]:

To Artifact [fae299202c]:

  • File src/OFList.m — part of check-in [4e59d2692f] at 2014-04-26 00:40:17 on branch trunk — Fix a few issues on LLP64 and Win64

    LLP64 was mostly fast enumeration using an unsigned long for the state,
    which can't store a pointer or a size_t on LLP64. This is now solved by
    either throwing an OFOutOfRangeException if the value of the size_t is
    bigger than ULONG_MAX or storing the pointer in the extra field (copied
    using memcpy, as it's an array of unsigned long, which again would be
    too small to store a pointer).

    Win64 was mostly Microsoft not being able to decide whether a length is
    a size_t, a DWORD, an int or an unsigned int (thus the different types
    in places that seem to be almost the same). But since that would not be
    confusing enough, a file descriptor is an int if it's for a file, but a
    long long if it is for a socket. But of course, for ReadFile and friends
    it's a DWORD instead of an int then. (user: js, size: 9439) [annotate] [blame] [check-ins using]


12
13
14
15
16
17
18
19

20
21
22
23
24
25
26
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include "assert.h"


#import "OFList.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFArray.h"

#import "OFEnumerationMutationException.h"







|
>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <string.h>
#include <assert.h>

#import "OFList.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFArray.h"

#import "OFEnumerationMutationException.h"
381
382
383
384
385
386
387
388
389


390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405


406
407
408
409
410
411
412
	return element;
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count
{
	of_list_object_t **listObject = (of_list_object_t**)&state->extra[0];
	int i;



	state->itemsPtr = objects;
	state->mutationsPtr = &_mutations;

	if (state->state == 0) {
		*listObject = _firstListObject;
		state->state = 1;
	}

	for (i = 0; i < count; i++) {
		if (*listObject == NULL)
			return i;

		objects[i] = (*listObject)->object;
		*listObject = (*listObject)->next;
	}



	return count;
}

- (OFEnumerator*)objectEnumerator
{
	return [[[OFListEnumerator alloc]







|

>
>





|




|


|
|

>
>







382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
	return element;
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count
{
	of_list_object_t *listObject;
	int i;

	memcpy(&listObject, state->extra, sizeof(listObject));

	state->itemsPtr = objects;
	state->mutationsPtr = &_mutations;

	if (state->state == 0) {
		listObject = _firstListObject;
		state->state = 1;
	}

	for (i = 0; i < count; i++) {
		if (listObject == NULL)
			return i;

		objects[i] = listObject->object;
		listObject = listObject->next;
	}

	memcpy(state->extra, &listObject, sizeof(listObject));

	return count;
}

- (OFEnumerator*)objectEnumerator
{
	return [[[OFListEnumerator alloc]