Deleted
Added
nxt_mp.c (737:8ca436f03869) | nxt_mp.c (832:4f5daf367ff7) |
---|---|
1 2/* 3 * Copyright (C) Igor Sysoev 4 * Copyright (C) NGINX, Inc. 5 */ 6 7#include <nxt_main.h> 8 --- 754 unchanged lines hidden (view full) --- 763static intptr_t 764nxt_mp_rbtree_compare(nxt_rbtree_node_t *node1, nxt_rbtree_node_t *node2) 765{ 766 nxt_mp_block_t *block1, *block2; 767 768 block1 = (nxt_mp_block_t *) node1; 769 block2 = (nxt_mp_block_t *) node2; 770 | 1 2/* 3 * Copyright (C) Igor Sysoev 4 * Copyright (C) NGINX, Inc. 5 */ 6 7#include <nxt_main.h> 8 --- 754 unchanged lines hidden (view full) --- 763static intptr_t 764nxt_mp_rbtree_compare(nxt_rbtree_node_t *node1, nxt_rbtree_node_t *node2) 765{ 766 nxt_mp_block_t *block1, *block2; 767 768 block1 = (nxt_mp_block_t *) node1; 769 block2 = (nxt_mp_block_t *) node2; 770 |
771 return (uintptr_t) block1->start - (uintptr_t) block2->start; | 771 /* 772 * Shifting is necessary to prevent overflow of intptr_t when block1->start 773 * is much greater than block2->start or vice versa. 774 * 775 * It is safe to drop one bit since there cannot be adjacent addresses 776 * because of alignments and allocation sizes. Effectively this reduces 777 * the absolute values to fit into the magnitude of intptr_t. 778 */ 779 return ((uintptr_t) block1->start >> 1) - ((uintptr_t) block2->start >> 1); |
772} 773 774 775void 776nxt_mp_free(nxt_mp_t *mp, void *p) 777{ 778 const char *err; 779 nxt_mp_block_t *block; --- 274 unchanged lines hidden --- | 780} 781 782 783void 784nxt_mp_free(nxt_mp_t *mp, void *p) 785{ 786 const char *err; 787 nxt_mp_block_t *block; --- 274 unchanged lines hidden --- |