Lines Matching refs:db

22 void handle_db_init(struct handle_db *db)  in handle_db_init()  argument
24 TEE_MemFill(db, 0, sizeof(*db)); in handle_db_init()
27 void handle_db_destroy(struct handle_db *db) in handle_db_destroy() argument
29 if (db) { in handle_db_destroy()
30 TEE_Free(db->ptrs); in handle_db_destroy()
31 db->ptrs = NULL; in handle_db_destroy()
32 db->max_ptrs = 0; in handle_db_destroy()
36 uint32_t handle_get(struct handle_db *db, void *ptr) in handle_get() argument
42 if (!db || !ptr || ptr == INVALID_HANDLE_PTR) in handle_get()
46 for (n = 1; n < db->max_ptrs; n++) { in handle_get()
47 if (!db->ptrs[n]) { in handle_get()
48 db->ptrs[n] = ptr; in handle_get()
54 if (db->max_ptrs) in handle_get()
55 new_max_ptrs = db->max_ptrs * 2; in handle_get()
59 p = TEE_Realloc(db->ptrs, new_max_ptrs * sizeof(void *)); in handle_get()
62 db->ptrs = p; in handle_get()
63 TEE_MemFill(db->ptrs + db->max_ptrs, 0, in handle_get()
64 (new_max_ptrs - db->max_ptrs) * sizeof(void *)); in handle_get()
65 db->max_ptrs = new_max_ptrs; in handle_get()
68 db->ptrs[n] = ptr; in handle_get()
72 static bool handle_is_valid(struct handle_db *db, uint32_t handle) in handle_is_valid() argument
74 return db && handle && handle < db->max_ptrs; in handle_is_valid()
77 void *handle_put(struct handle_db *db, uint32_t handle) in handle_put() argument
81 if (!handle_is_valid(db, handle)) in handle_put()
84 p = db->ptrs[handle]; in handle_put()
85 db->ptrs[handle] = NULL; in handle_put()
89 void *handle_lookup(struct handle_db *db, uint32_t handle) in handle_lookup() argument
91 if (!handle_is_valid(db, handle) || in handle_lookup()
92 db->ptrs[handle] == INVALID_HANDLE_PTR) in handle_lookup()
95 return db->ptrs[handle]; in handle_lookup()
98 void handle_invalidate(struct handle_db *db, uint32_t handle) in handle_invalidate() argument
100 if (handle_is_valid(db, handle)) { in handle_invalidate()
101 if (!db->ptrs[handle]) in handle_invalidate()
104 db->ptrs[handle] = INVALID_HANDLE_PTR; in handle_invalidate()
108 uint32_t handle_lookup_handle(struct handle_db *db, void *ptr) in handle_lookup_handle() argument
113 for (n = 1; n < db->max_ptrs; n++) in handle_lookup_handle()
114 if (db->ptrs[n] == ptr) in handle_lookup_handle()