ucx/utils.c

changeset 110
53895e9a4bbb
parent 70
88092b88ec00
child 255
bf19378aed58
equal deleted inserted replaced
109:020a5b5aa510 110:53895e9a4bbb
1 /* 1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 * 3 *
4 * Copyright 2014 Olaf Wintermann. All rights reserved. 4 * Copyright 2015 Olaf Wintermann. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met: 7 * modification, are permitted provided that the following conditions are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
126 return a < b ? -1 : 1; 126 return a < b ? -1 : 1;
127 } 127 }
128 } 128 }
129 129
130 int ucx_ptrcmp(void *ptr1, void *ptr2, void *data) { 130 int ucx_ptrcmp(void *ptr1, void *ptr2, void *data) {
131 if (ptr1 == ptr2) { 131 intptr_t p1 = (intptr_t) ptr1;
132 intptr_t p2 = (intptr_t) ptr2;
133 if (p1 == p2) {
132 return 0; 134 return 0;
133 } else { 135 } else {
134 return ptr1 < ptr2 ? -1 : 1; 136 return p1 < p2 ? -1 : 1;
135 } 137 }
136 } 138 }
137 139
138 int ucx_memcmp(void *ptr1, void *ptr2, void *n) { 140 int ucx_memcmp(void *ptr1, void *ptr2, void *n) {
139 return memcmp(ptr1, ptr2, *((size_t*)n)); 141 return memcmp(ptr1, ptr2, *((size_t*)n));

mercurial