diff options
| author | Tyge Løvset <[email protected]> | 2020-03-20 15:28:50 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-03-20 15:28:50 +0100 |
| commit | 312c7feaa0d1475b836d26f6ddb53b67d6a2e803 (patch) | |
| tree | 666433a897d29d623979fd3c93ba28dbe8364aad | |
| parent | a65478b5d96723134399ea2aa5de35ed265e0f1d (diff) | |
| download | STC-modified-312c7feaa0d1475b836d26f6ddb53b67d6a2e803.tar.gz STC-modified-312c7feaa0d1475b836d26f6ddb53b67d6a2e803.zip | |
Update EXAMPLE.md
| -rw-r--r-- | EXAMPLE.md | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -29,11 +29,11 @@ void person_destroy(struct Person* p) { cstring_destroy(&p->surname);
}
-int person_compare(const struct Person* x, const struct Person *y, size_t ignore) {
+int person_compare(struct Person x, struct Person y) {
int c;
- c = strcmp(x->name.str, y->name.str); if (c != 0) return c;
- c = strcmp(x->surname.str, y->surname.str); if (c != 0) return c;
- return memcmp(&x->age, &y->age, sizeof(x->age));
+ c = strcmp(x.name.str, y.name.str); if (c != 0) return c;
+ c = strcmp(x.surname.str, y.surname.str); if (c != 0) return c;
+ return memcmp(&x.age, &y.age, sizeof(x.age));
}
```
Here is a simple hash function that combines the three member's hashes:
@@ -52,7 +52,7 @@ size_t person_hash(const struct Person* p, size_t ignore) { With this in place, you can instantiate a CMap with Person => CString:
```
#include <c_lib/CMap.h>
-declare_CMap(ex, struct Person, CString, cstring_destroy, person_compare, person_hash, person_destroy);
+declare_CMap(ex, struct Person, CString, cstring_destroy, person_hash, person_compare, person_destroy);
int main()
{
|
