-
Notifications
You must be signed in to change notification settings - Fork 0
/
td_put.c
44 lines (40 loc) · 1.17 KB
/
td_put.c
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
/*
** Copyright 2015 K.J. Hermans (kees.jan.hermans@gmail.com)
** This code is part of simpledbm, an API to a dbm on a finite resource.
** License: BSD
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "td_private.h"
/**
* \ingroup btree
*
* Puts a value into the tree, under a certain key.
*
* Values will be either newly inserted (when the key is not present),
* replaced (when the key is present and TDFLG_DUPLKEYS has not been set during
* initialization), or added (when the key is present and TDFLG_DUPLKEYS
* has been set during initialization).
*
* \param td Pointer to an initialized td_t structure.
* \param key Pointer to an initialized tdt_t structure, containing the key.
* \param value Pointer to an initialized tdt_t structure, containing the value.
* \param flags May be used to tweak the way the key/value pair is stored.
*
* \returns Zero on success, or any of the errors of the underlying
* functions.
*/
int td_put
(td_t* td, const tdt_t* key, const tdt_t* value, unsigned flags)
{
int r;
flags |= td->header.flags;
CHECK(td_lock(td));
r = td_put_locked_key(td, key, value, 1, flags);
CHECK(td_unlock(td));
return r;
}
#ifdef __cplusplus
}
#endif