Skip to content

Commit 72c01ed

Browse files
author
Tyge Lovset
committed
Changed all container's copy() function. Other argument is now value (not pointer) like for clone().
1 parent cf07e8c commit 72c01ed

21 files changed

+34
-35
lines changed

Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ $(OBJ_DIR)/%$(DOTEXE): %.c $(LIB_PATH)
9393

9494
$(TEST_EXE): $(TEST_OBJS)
9595
@printf "\r\e[2K%s" "$(CC) -o $@"
96-
@echo
9796
@$(CC) -o $@ $(TEST_OBJS) -s $(LDFLAGS) -L$(BUILDDIR) -l$(LIB_NAME)
9897

9998

docs/cbits_api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ cbits cbits_with_pattern(isize size, size_t pattern);
2929
cbits cbits_clone(cbits other);
3030

3131
void cbits_clear(cbits* self);
32-
cbits* cbits_copy(cbits* self, const cbits* other);
32+
void cbits_copy(cbits* self, cbits other);
3333
bool cbits_resize(cbits* self, isize size, bool value); // NB! only for dynamic bitsets!
3434
void cbits_drop(cbits* self);
3535

docs/deq_api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ deq_X deq_X_with_capacity(intptr_t size);
3535
deq_X deq_X_clone(deq_X deq);
3636
3737
void deq_X_clear(deq_X* self);
38-
void deq_X_copy(deq_X* self, const deq_X* other);
38+
void deq_X_copy(deq_X* self, deq_X other);
3939
bool deq_X_reserve(deq_X* self, intptr_t cap);
4040
void deq_X_shrink_to_fit(deq_X* self);
4141
void deq_X_drop(deq_X* self); // destructor

docs/deque_api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ deque_X deque_X_init(void);
4343
deque_X deque_X_with_capacity(isize size);
4444

4545
deque_X deque_X_clone(deque_X deque);
46-
void deque_X_copy(deque_X* self, const deque_X* other);
46+
void deque_X_copy(deque_X* self, deque_X other);
4747
void deque_X_take(deque_X* self, deque_X unowned); // take ownership of unowned
4848
deque_X deque_X_move(deque_X* self); // move
4949
void deque_X_drop(deque_X* self); // destructor

docs/hmap_api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ hmap_X hmap_X_init(void);
5656
hmap_X hmap_X_with_capacity(isize cap);
5757

5858
hmap_X hmap_X_clone(hmap_x map);
59-
void hmap_X_copy(hmap_X* self, const hmap_X* other);
59+
void hmap_X_copy(hmap_X* self, hmap_X other);
6060
void hmap_X_take(hmap_X* self, hmap_X unowned); // take ownership of unowned
6161
hmap_X hmap_X_move(hmap_X* self); // move
6262
void hmap_X_drop(hmap_X* self); // destructor

docs/hset_api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ hset_X hset_X_init(void);
3636
hset_X hset_X_with_capacity(isize cap);
3737

3838
hset_X hset_X_clone(hset_x set);
39-
void hset_X_copy(hset_X* self, const hset_X* other);
39+
void hset_X_copy(hset_X* self, hset_X other);
4040
void hset_X_take(hset_X* self, hset_X unowned); // take ownership of unowned
4141
hset_X hset_X_move(hset_X* self); // move
4242
void hset_X_drop(hset_X* self); // destructor

docs/list_api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ See the c++ class [std::list](https://en.cppreference.com/w/cpp/container/list)
5353
list_X list_X_init(void);
5454
5555
list_X list_X_clone(list_X list);
56-
void list_X_copy(list_X* self, const list_X* other);
56+
void list_X_copy(list_X* self, list_X other);
5757
void list_X_take(list_X* self, list_X unowned); // take ownership of unowned
5858
list_X list_X_move(list_X* self); // move
5959
void list_X_drop(list_X* self); // destructor

docs/pqueue_api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pqueue_X pqueue_X_with_capacity(isize cap);
3939
pqueue_X pqueue_X_with_size(isize size, i_key null);
4040

4141
pqueue_X pqueue_X_clone(pqueue_X pq);
42-
void pqueue_X_copy(pqueue_X* self, const pqueue_X* other);
42+
void pqueue_X_copy(pqueue_X* self, pqueue_X other);
4343
void pqueue_X_take(pqueue_X* self, pqueue_X unowned); // take ownership of unowned
4444
pqueue_X pqueue_X_move(pqueue_X* self); // move
4545
void pqueue_X_drop(pqueue_X* self); // destructor

docs/queue_api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ queue_X queue_X_init(void);
3434
queue_X queue_X_with_capacity(isize size);
3535

3636
queue_X queue_X_clone(queue_X q);
37-
void queue_X_copy(queue_X* self, const queue_X* other);
37+
void queue_X_copy(queue_X* self, queue_X other);
3838
void queue_X_take(queue_X* self, queue_X unowned); // take ownership of unowned
3939
queue_X queue_X_move(queue_X* self); // move
4040
void queue_X_drop(queue_X* self); // destructor

docs/smap_api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ smap_X smap_X_init(void);
5656
sset_X smap_X_with_capacity(isize cap);
5757

5858
smap_X smap_X_clone(smap_x map);
59-
void smap_X_copy(smap_X* self, const smap_X* other);
59+
void smap_X_copy(smap_X* self, smap_X other);
6060
void smap_X_take(smap_X* self, smap_X unowned); // take ownership of unowned
6161
smap_X smap_X_move(smap_X* self); // move
6262
void smap_X_drop(smap_X* self); // destructor

docs/sset_api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ sset_X sset_X_init(void);
3939
sset_X sset_X_with_capacity(isize cap);
4040

4141
sset_X sset_X_clone(sset_x set);
42-
void sset_X_copy(sset_X* self, const sset_X* other);
42+
void sset_X_copy(sset_X* self, sset_X other);
4343
void sset_X_take(sset_X* self, sset_X unowned); // take ownership of unowned
4444
sset_X sset_X_move(sset_X* self); // move
4545
void sset_X_drop(sset_X* self); // destructor

docs/stack_api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ stack_X stack_X_with_capacity(isize cap);
4343
stack_X stack_X_with_size(isize size, i_key fill);
4444

4545
stack_X stack_X_clone(stack_X st);
46-
void stack_X_copy(stack_X* self, const stack_X* other);
46+
void stack_X_copy(stack_X* self, stack_X other);
4747
stack_X stack_X_move(stack_X* self); // move
4848
void stack_X_take(stack_X* self, stack_X unowned); // take ownership of unowned
4949
void stack_X_drop(stack_X* self); // destructor

docs/vec_api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ vec_X vec_X_with_size(isize size, i_key null);
4646
vec_X vec_X_with_capacity(isize size);
4747
vec_X vec_X_clone(vec_X vec);
4848

49-
void vec_X_copy(vec_X* self, const vec_X* other);
49+
void vec_X_copy(vec_X* self, vec_X other);
5050
vec_X_iter vec_X_copy_n(vec_X* self, isize idx, const i_key* arr, isize n);
5151
vec_X vec_X_move(vec_X* self); // move
5252
void vec_X_take(vec_X* self, vec_X unowned); // take ownership of unowned

include/stc/cbits.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ STC_INLINE isize _i_MEMB(_size)(const Self* self) { (void)self; return _i_len
229229
STC_INLINE Self _i_MEMB(_move)(Self* self) { return *self; }
230230
STC_INLINE Self* _i_MEMB(_take)(Self* self, Self other) { *self = other; return self; }
231231
STC_INLINE Self _i_MEMB(_clone)(Self other) { return other; }
232-
STC_INLINE Self* _i_MEMB(_copy)(Self* self, const Self* other) { *self = *other; return self; }
232+
STC_INLINE void _i_MEMB(_copy)(Self* self, const Self other) { *self = other; }
233233
STC_INLINE void _i_MEMB(_set_all)(Self *self, const bool value);
234234
STC_INLINE void _i_MEMB(_set_pattern)(Self *self, const uintptr_t pattern);
235235

include/stc/hmap.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ _c_MEMB(_insert_entry_)(Self* self, _m_keyraw rkey) {
141141
#endif // _i_is_map
142142

143143
#if !defined i_no_clone
144-
STC_INLINE void _c_MEMB(_copy)(Self *self, const Self* other) {
145-
if (self->table == other->table)
144+
STC_INLINE void _c_MEMB(_copy)(Self *self, const Self other) {
145+
if (self->table == other.table)
146146
return;
147147
_c_MEMB(_drop)(self);
148-
*self = _c_MEMB(_clone)(*other);
148+
*self = _c_MEMB(_clone)(other);
149149
}
150150

151151
STC_INLINE _m_value _c_MEMB(_value_clone)(_m_value _val) {

include/stc/list.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ STC_API Self _c_MEMB(_clone)(Self cx);
121121
STC_INLINE _m_value _c_MEMB(_value_clone)(_m_value val) { return i_keyclone(val); }
122122

123123
STC_INLINE void
124-
_c_MEMB(_copy)(Self *self, const Self* other) {
125-
if (self->last == other->last) return;
126-
_c_MEMB(_drop)(self); *self = _c_MEMB(_clone)(*other);
124+
_c_MEMB(_copy)(Self *self, const Self other) {
125+
if (self->last == other.last) return;
126+
_c_MEMB(_drop)(self); *self = _c_MEMB(_clone)(other);
127127
}
128128
#endif // !i_no_clone
129129

include/stc/pqueue.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ STC_INLINE _m_value _c_MEMB(_pull)(Self* self)
115115
#if !defined i_no_clone
116116
STC_API Self _c_MEMB(_clone)(Self q);
117117

118-
STC_INLINE void _c_MEMB(_copy)(Self *self, const Self* other) {
119-
if (self->data == other->data) return;
118+
STC_INLINE void _c_MEMB(_copy)(Self *self, const Self other) {
119+
if (self->data == other.data) return;
120120
_c_MEMB(_drop)(self);
121-
*self = _c_MEMB(_clone)(*other);
121+
*self = _c_MEMB(_clone)(other);
122122
}
123123
STC_INLINE _m_value _c_MEMB(_value_clone)(_m_value val)
124124
{ return i_keyclone(val); }

include/stc/priv/queue_prv.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ STC_API Self _c_MEMB(_clone)(Self cx);
6363
STC_INLINE _m_value _c_MEMB(_value_clone)(_m_value val)
6464
{ return i_keyclone(val); }
6565

66-
STC_INLINE void _c_MEMB(_copy)(Self* self, const Self* other) {
67-
if (self->cbuf == other->cbuf) return;
66+
STC_INLINE void _c_MEMB(_copy)(Self* self, const Self other) {
67+
if (self->cbuf == other.cbuf) return;
6868
_c_MEMB(_drop)(self);
69-
*self = _c_MEMB(_clone)(*other);
69+
*self = _c_MEMB(_clone)(other);
7070
}
7171
#endif // !i_no_clone
7272
STC_INLINE isize _c_MEMB(_size)(const Self* self)

include/stc/smap.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ STC_INLINE _m_value _c_MEMB(_value_clone)(_m_value _val) {
162162
return _val;
163163
}
164164

165-
STC_INLINE void _c_MEMB(_copy)(Self *self, const Self* other) {
166-
if (self->nodes == other->nodes)
165+
STC_INLINE void _c_MEMB(_copy)(Self *self, const Self other) {
166+
if (self->nodes == other.nodes)
167167
return;
168168
_c_MEMB(_drop)(self);
169-
*self = _c_MEMB(_clone)(*other);
169+
*self = _c_MEMB(_clone)(other);
170170
}
171171

172172
STC_INLINE void _c_MEMB(_shrink_to_fit)(Self *self) {

include/stc/stack.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ STC_INLINE Self _c_MEMB(_clone)(Self s) {
187187
return s;
188188
}
189189

190-
STC_INLINE void _c_MEMB(_copy)(Self *self, const Self* other) {
191-
if (self->data == other->data) return;
190+
STC_INLINE void _c_MEMB(_copy)(Self *self, const Self other) {
191+
if (self->data == other.data) return;
192192
_c_MEMB(_drop)(self);
193-
*self = _c_MEMB(_clone)(*other);
193+
*self = _c_MEMB(_clone)(other);
194194
}
195195

196196
STC_INLINE _m_value _c_MEMB(_value_clone)(_m_value val)

include/stc/vec.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ STC_API _m_iter _c_MEMB(_copy_n)(Self* self, isize idx, const _m_value a
136136
STC_INLINE _m_value _c_MEMB(_value_clone)(_m_value val)
137137
{ return i_keyclone(val); }
138138

139-
STC_INLINE void _c_MEMB(_copy)(Self* self, const Self* other) {
140-
if (self->data == other->data) return;
139+
STC_INLINE void _c_MEMB(_copy)(Self* self, const Self other) {
140+
if (self->data == other.data) return;
141141
_c_MEMB(_clear)(self);
142-
_c_MEMB(_copy_n)(self, 0, other->data, other->size);
142+
_c_MEMB(_copy_n)(self, 0, other.data, other.size);
143143
}
144144
#endif // !i_no_clone
145145

0 commit comments

Comments
 (0)