File: dict.c

package info (click to toggle)
openmpi 5.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 202,312 kB
  • sloc: ansic: 612,441; makefile: 42,495; sh: 11,230; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,154; python: 1,856; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (79 lines) | stat: -rw-r--r-- 1,538 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
 * dict.c
 *
 * Implementation of generic dictionary routines.
 * Copyright (C) 2001-2004 Farooq Mela.
 * Copyright (c) 2022      IBM Corporation.  All rights reserved.
 *
 * $Id: dict.c,v 1.7 2001/11/25 06:00:49 farooq Exp farooq $
 */

#include <stdlib.h>

#include "dict.h"
#include "dict_private.h"

dict_malloc_func ompi_coll_libnbc_dict_malloc = malloc;
dict_free_func ompi_coll_libnbc_dict_free = free;

int
ompi_coll_libnbc_dict_uint_cmp(const void *k1, const void *k2)
{
	const unsigned int *a = (unsigned int*)k1, *b = (unsigned int*)k2;

	return (*a < *b) ? -1 : (*a > *b) ? +1 : 0;
}

int
ompi_coll_libnbc_dict_long_cmp(const void *k1, const void *k2)
{
	const long *a = (long*)k1, *b = (long*)k2;

	return (*a < *b) ? -1 : (*a > *b) ? +1 : 0;
}

int
ompi_coll_libnbc_dict_ulong_cmp(const void *k1, const void *k2)
{
	const unsigned long *a = (unsigned long*)k1, *b = (unsigned long*)k2;

	return (*a < *b) ? -1 : (*a > *b) ? +1 : 0;
}

int
ompi_coll_libnbc_dict_ptr_cmp(const void *k1, const void *k2)
{
	return (k1 > k2) - (k1 < k2);
}

int
ompi_coll_libnbc_dict_str_cmp(const void *k1, const void *k2)
{
	const char *a = (char*)k1, *b = (char*)k2;
	char p, q;

	for (;;) {
		p = *a++; q = *b++;
		if (p == 0 || p != q)
			break;
	}
	return (p > q) - (p < q);
}

void
ompi_coll_libnbc_dict_destroy(dict *dct, int del)
{
	ASSERT(dct != NULL);

	dct->_destroy(dct->_object, del);
	FREE(dct);
}

void
ompi_coll_libnbc_dict_itor_destroy(dict_itor *itor)
{
	ASSERT(itor != NULL);

	itor->_destroy(itor->_itor);
	FREE(itor);
}