Differences From Artifact [c52dab0d6d]:
- File
src/OFMutableData.m
— part of check-in
[627511b032]
at
2020-11-14 12:23:55
on branch trunk
— Rename of_malloc and of_calloc
The new names should be more accurate. (user: js, size: 6655) [annotate] [blame] [check-ins using] [more...]
To Artifact [01aa579278]:
- File src/OFMutableData.m — part of check-in [1b82d3bf4f] at 2021-03-07 20:25:21 on branch trunk — *.m: Fold methods into one line where it fits (user: js, size: 6514) [annotate] [blame] [check-ins using] [more...]
1 | /* | < < | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * |
︙ | ︙ | |||
40 41 42 43 44 45 46 | } + (instancetype)dataWithCapacity: (size_t)capacity { return [[[self alloc] initWithCapacity: capacity] autorelease]; } | | < | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | } + (instancetype)dataWithCapacity: (size_t)capacity { return [[[self alloc] initWithCapacity: capacity] autorelease]; } + (instancetype)dataWithItemSize: (size_t)itemSize capacity: (size_t)capacity { return [[[self alloc] initWithItemSize: itemSize capacity: capacity] autorelease]; } - (instancetype)init { |
︙ | ︙ | |||
81 82 83 84 85 86 87 | - (instancetype)initWithCapacity: (size_t)capacity { return [self initWithItemSize: 1 capacity: capacity]; } | | < | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | - (instancetype)initWithCapacity: (size_t)capacity { return [self initWithItemSize: 1 capacity: capacity]; } - (instancetype)initWithItemSize: (size_t)itemSize capacity: (size_t)capacity { self = [super init]; @try { if (itemSize == 0) @throw [OFInvalidArgumentException exception]; |
︙ | ︙ | |||
106 107 108 109 110 111 112 | return self; } - (instancetype)initWithItems: (const void *)items count: (size_t)count itemSize: (size_t)itemSize { | | < < | < < | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | return self; } - (instancetype)initWithItems: (const void *)items count: (size_t)count itemSize: (size_t)itemSize { self = [super initWithItems: items count: count itemSize: itemSize]; _capacity = _count; return self; } - (instancetype)initWithItemsNoCopy: (void *)items count: (size_t)count itemSize: (size_t)itemSize freeWhenDone: (bool)freeWhenDone { self = [self initWithItems: items count: count itemSize: itemSize]; if (freeWhenDone) free(items); return self; } |
︙ | ︙ | |||
194 195 196 197 198 199 200 | } memcpy(_items + _count * _itemSize, item, _itemSize); _count++; } | | < | < < | < | 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | } memcpy(_items + _count * _itemSize, item, _itemSize); _count++; } - (void)insertItem: (const void *)item atIndex: (size_t)idx { [self insertItems: item atIndex: idx count: 1]; } - (void)addItems: (const void *)items count: (size_t)count { if (count > SIZE_MAX - _count) @throw [OFOutOfRangeException exception]; if (_count + count > _capacity) { _items = of_realloc(_items, _count + count, _itemSize); _capacity = _count + count; |
︙ | ︙ |