MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / pthread_key_create

Function pthread_key_create

include/hamlib/winpthreads.h:1086–1175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1084*/
1085
1086static int pthread_key_create(pthread_key_t *key, void (* dest)(void *))
1087{
1088 unsigned i;
1089 long nmax;
1090 void (**d)(void *);
1091
1092 if (!key) return EINVAL;
1093
1094 pthread_rwlock_wrlock(&_pthread_key_lock);
1095
1096 for (i = _pthread_key_sch; i < _pthread_key_max; i++)
1097 {
1098 if (!_pthread_key_dest[i])
1099 {
1100 *key = i;
1101 if (dest)
1102 {
1103 _pthread_key_dest[i] = dest;
1104 }
1105 else
1106 {
1107 _pthread_key_dest[i] = (void(*)(void *))1;
1108 }
1109 pthread_rwlock_unlock(&_pthread_key_lock);
1110
1111 return 0;
1112 }
1113 }
1114
1115 for (i = 0; i < _pthread_key_sch; i++)
1116 {
1117 if (!_pthread_key_dest[i])
1118 {
1119 *key = i;
1120 if (dest)
1121 {
1122 _pthread_key_dest[i] = dest;
1123 }
1124 else
1125 {
1126 _pthread_key_dest[i] = (void(*)(void *))1;
1127 }
1128 pthread_rwlock_unlock(&_pthread_key_lock);
1129
1130 return 0;
1131 }
1132 }
1133
1134 if (!_pthread_key_max) _pthread_key_max = 1;
1135 if (_pthread_key_max == PTHREAD_KEYS_MAX)
1136 {
1137 pthread_rwlock_unlock(&_pthread_key_lock);
1138
1139 return ENOMEM;
1140 }
1141
1142 nmax = _pthread_key_max * 2;
1143 if (nmax > PTHREAD_KEYS_MAX) nmax = PTHREAD_KEYS_MAX;

Callers 1

rigctl_parse_initFunction · 0.85

Calls 2

pthread_rwlock_wrlockFunction · 0.85
pthread_rwlock_unlockFunction · 0.85

Tested by

no test coverage detected