Пример #1
0
size_t scatter(void const * memory, size_t extent, struct field const * field, unsigned fields)

{
	byte const * source = (byte const *) (memory);
	while ((fields--) && (field->size < extent))
	{
		if (! field->type)
		{
			memcopy (field->base, source, field->size);
		}
		else 
		{
			memfold (field->base, source, field->size);
		}
		source += field->size;
		extent -= field->size;
		field++;
	}
	return (source - (byte *) (memory));
}
Пример #2
0
size_t gather (void * memory, size_t extent, struct field const * field, unsigned fields) 

{
	byte * target = (byte *)(memory);
	while ((fields--) && (field->size < extent)) 
	{
		if (!field->type) 
		{
			memcopy (target, field->base, field->size);
		}
		else 
		{
			memfold (target, field->base, field->size);
		}
		target += field->size;
		extent -= field->size;
		field++;
	}
	return (target - (byte *)(memory));
}