diff options
Diffstat (limited to 'src/lib/libssl/pqueue.c')
| -rw-r--r-- | src/lib/libssl/pqueue.c | 37 |
1 files changed, 7 insertions, 30 deletions
diff --git a/src/lib/libssl/pqueue.c b/src/lib/libssl/pqueue.c index 99c118c3b6..daf5e21b3a 100644 --- a/src/lib/libssl/pqueue.c +++ b/src/lib/libssl/pqueue.c | |||
| @@ -84,30 +84,18 @@ pitem_new(unsigned char *prio64be, void *data) | |||
| 84 | void | 84 | void |
| 85 | pitem_free(pitem *item) | 85 | pitem_free(pitem *item) |
| 86 | { | 86 | { |
| 87 | if (item == NULL) | ||
| 88 | return; | ||
| 89 | |||
| 90 | free(item); | 87 | free(item); |
| 91 | } | 88 | } |
| 92 | 89 | ||
| 93 | pqueue_s * | 90 | pqueue_s * |
| 94 | pqueue_new(void) | 91 | pqueue_new(void) |
| 95 | { | 92 | { |
| 96 | pqueue_s *pq = (pqueue_s *)malloc(sizeof(pqueue_s)); | 93 | return (pqueue_s *)calloc(1, sizeof(pqueue_s)); |
| 97 | |||
| 98 | if (pq == NULL) | ||
| 99 | return NULL; | ||
| 100 | |||
| 101 | memset(pq, 0x00, sizeof(pqueue_s)); | ||
| 102 | return pq; | ||
| 103 | } | 94 | } |
| 104 | 95 | ||
| 105 | void | 96 | void |
| 106 | pqueue_free(pqueue_s *pq) | 97 | pqueue_free(pqueue_s *pq) |
| 107 | { | 98 | { |
| 108 | if (pq == NULL) | ||
| 109 | return; | ||
| 110 | |||
| 111 | free(pq); | 99 | free(pq); |
| 112 | } | 100 | } |
| 113 | 101 | ||
| @@ -126,9 +114,8 @@ pqueue_insert(pqueue_s *pq, pitem *item) | |||
| 126 | /* we can compare 64-bit value in big-endian encoding | 114 | /* we can compare 64-bit value in big-endian encoding |
| 127 | * with memcmp:-) */ | 115 | * with memcmp:-) */ |
| 128 | int cmp = memcmp(next->priority, item->priority, | 116 | int cmp = memcmp(next->priority, item->priority, |
| 129 | sizeof(item->priority)); | 117 | sizeof(item->priority)); |
| 130 | if (cmp > 0) /* next > item */ | 118 | if (cmp > 0) { /* next > item */ |
| 131 | { | ||
| 132 | item->next = next; | 119 | item->next = next; |
| 133 | 120 | ||
| 134 | if (curr == NULL) | 121 | if (curr == NULL) |
| @@ -168,23 +155,13 @@ pitem * | |||
| 168 | pqueue_find(pqueue_s *pq, unsigned char *prio64be) | 155 | pqueue_find(pqueue_s *pq, unsigned char *prio64be) |
| 169 | { | 156 | { |
| 170 | pitem *next; | 157 | pitem *next; |
| 171 | pitem *found = NULL; | ||
| 172 | 158 | ||
| 173 | if (pq->items == NULL) | 159 | for (next = pq->items; next != NULL; next = next->next) |
| 174 | return NULL; | ||
| 175 | |||
| 176 | for (next = pq->items; next != NULL; next = next->next) { | ||
| 177 | if (memcmp(next->priority, prio64be, | 160 | if (memcmp(next->priority, prio64be, |
| 178 | sizeof(next->priority)) == 0) { | 161 | sizeof(next->priority)) == 0) |
| 179 | found = next; | 162 | return next; |
| 180 | break; | ||
| 181 | } | ||
| 182 | } | ||
| 183 | |||
| 184 | if (!found) | ||
| 185 | return NULL; | ||
| 186 | 163 | ||
| 187 | return found; | 164 | return NULL; |
| 188 | } | 165 | } |
| 189 | 166 | ||
| 190 | pitem * | 167 | pitem * |
