Lines Matching +full:- +full:n
1 // SPDX-License-Identifier: BSD-2-Clause
22 size_t n = 0; in handle_db_destroy() local
24 for (n = 0; n < db->max_ptrs; n++) in handle_db_destroy()
25 if (db->ptrs[n]) in handle_db_destroy()
26 ptr_destructor(db->ptrs[n]); in handle_db_destroy()
28 free(db->ptrs); in handle_db_destroy()
29 db->ptrs = NULL; in handle_db_destroy()
30 db->max_ptrs = 0; in handle_db_destroy()
36 size_t n = 0; in handle_db_is_empty() local
39 for (n = 0; n < db->max_ptrs; n++) { in handle_db_is_empty()
40 if (db->ptrs[n]) in handle_db_is_empty()
49 size_t n; in handle_get() local
54 return -1; in handle_get()
57 for (n = 0; n < db->max_ptrs; n++) { in handle_get()
58 if (!db->ptrs[n]) { in handle_get()
59 db->ptrs[n] = ptr; in handle_get()
60 return n; in handle_get()
65 if (db->max_ptrs) in handle_get()
66 new_max_ptrs = db->max_ptrs * 2; in handle_get()
69 p = realloc(db->ptrs, new_max_ptrs * sizeof(void *)); in handle_get()
71 return -1; in handle_get()
72 db->ptrs = p; in handle_get()
73 memset(db->ptrs + db->max_ptrs, 0, in handle_get()
74 (new_max_ptrs - db->max_ptrs) * sizeof(void *)); in handle_get()
75 db->max_ptrs = new_max_ptrs; in handle_get()
77 /* Since n stopped at db->max_ptrs there is an empty location there */ in handle_get()
78 db->ptrs[n] = ptr; in handle_get()
79 return n; in handle_get()
86 if (!db || handle < 0 || (size_t)handle >= db->max_ptrs) in handle_put()
89 p = db->ptrs[handle]; in handle_put()
90 db->ptrs[handle] = NULL; in handle_put()
96 if (!db || handle < 0 || (size_t)handle >= db->max_ptrs) in handle_lookup()
99 return db->ptrs[handle]; in handle_lookup()