diff options
| author | Tyge Løvset <[email protected]> | 2020-12-09 11:46:15 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-12-09 11:46:15 +0100 |
| commit | 30a400f71df76c077c97590b7a60daba98bef396 (patch) | |
| tree | b8bd823f0bcb8170c3c8c66c881c73573f8fa85c /stc | |
| parent | b28159c2b1d4f477f78a2434a9a25caeb2a2e898 (diff) | |
| download | STC-modified-30a400f71df76c077c97590b7a60daba98bef396.tar.gz STC-modified-30a400f71df76c077c97590b7a60daba98bef396.zip | |
Renamed cptr_X type to cuptr_X, as it is similar to a unique_ptr, rather than a bare pointer. More docs too.
Diffstat (limited to 'stc')
| -rw-r--r-- | stc/cptr.h | 33 |
1 files changed, 17 insertions, 16 deletions
@@ -23,7 +23,8 @@ #ifndef CPTR__H__
#define CPTR__H__
-/* cptr: pointers in containers, csptr: std::unique_ptr -like type:
+/* cuptr: std::unique_ptr -like type */
+/*
#include <stc/cptr.h>
#include <stc/cstr.h>
#include <stc/cvec.h>
@@ -43,8 +44,8 @@ int Person_compare(const Person* p, const Person* q) { return cmp == 0 ? strcmp(p->last.str, q->last.str) : cmp;
}
-using_cptr(pe, Person, Person_del, Person_compare);
-using_cvec(pe, Person*, cptr_pe_del, cptr_pe_compare);
+using_cuptr(pe, Person, Person_del, Person_compare);
+using_cvec(pe, Person*, cuptr_pe_del, cuptr_pe_compare);
int main() {
cvec_pe vec = cvec_pe_init();
@@ -58,35 +59,35 @@ int main() { */
#include "ccommon.h"
-#define using_cptr(...) c_MACRO_OVERLOAD(using_cptr, __VA_ARGS__)
+#define using_cuptr(...) c_MACRO_OVERLOAD(using_cuptr, __VA_ARGS__)
-#define using_cptr_2(X, Value) \
- using_cptr_3(X, Value, c_default_del)
+#define using_cuptr_2(X, Value) \
+ using_cuptr_3(X, Value, c_default_del)
-#define using_cptr_3(X, Value, valueDestroy) \
- using_cptr_4(X, Value, valueDestroy, c_default_compare)
+#define using_cuptr_3(X, Value, valueDestroy) \
+ using_cuptr_4(X, Value, valueDestroy, c_default_compare)
-#define using_cptr_4(X, Value, valueDestroy, valueCompare) \
- typedef Value cptr_##X##_value_t; \
- typedef cptr_##X##_value_t *cptr_##X; \
+#define using_cuptr_4(X, Value, valueDestroy, valueCompare) \
+ typedef Value cuptr_##X##_value_t; \
+ typedef cuptr_##X##_value_t *cuptr_##X; \
\
STC_INLINE void \
- cptr_##X##_del(cptr_##X* self) { \
+ cuptr_##X##_del(cuptr_##X* self) { \
valueDestroy(*self); \
c_free(*self); \
} \
\
STC_INLINE void \
- cptr_##X##_reset(cptr_##X* self, cptr_##X##_value_t* p) { \
- cptr_##X##_del(self); \
+ cuptr_##X##_reset(cuptr_##X* self, cuptr_##X##_value_t* p) { \
+ cuptr_##X##_del(self); \
*self = p; \
} \
\
STC_INLINE int \
- cptr_##X##_compare(cptr_##X* x, cptr_##X* y) { \
+ cuptr_##X##_compare(cuptr_##X* x, cuptr_##X* y) { \
return valueCompare(*x, *y); \
} \
- typedef cptr_##X cptr_##X##_t
+ typedef cuptr_##X cuptr_##X##_t
|
