projects
/
m6w6
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Standardize the snprintf() failure messages, and add tests for libmemcached_util_getpid()
[m6w6/libmemcached]
/
example
/
storage.c
diff --git
a/example/storage.c
b/example/storage.c
index 72439361bde166d990819f130016382e254f3d2c..1fb79730eba16436ee2257d1e18efb20518d0a6b 100644
(file)
--- a/
example/storage.c
+++ b/
example/storage.c
@@
-1,4
+1,5
@@
/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */
+#include "config.h"
#include <stdlib.h>
#include <inttypes.h>
#include <time.h>
#include <stdlib.h>
#include <inttypes.h>
#include <time.h>
@@
-15,16
+16,20
@@
struct list_entry {
static struct list_entry *root;
static uint64_t cas;
static struct list_entry *root;
static uint64_t cas;
-bool initialize_storage(void) {
+bool initialize_storage(void)
+{
return true;
}
return true;
}
-void shutdown_storage(void) {
+void shutdown_storage(void)
+{
/* Do nothing */
}
/* Do nothing */
}
-void put_item(struct item* item) {
+void put_item(struct item* item)
+{
struct list_entry* entry= (void*)item;
struct list_entry* entry= (void*)item;
+
update_cas(item);
if (root == NULL)
update_cas(item);
if (root == NULL)
@@
-42,8
+47,10
@@
void put_item(struct item* item) {
root= entry;
}
root= entry;
}
-struct item* get_item(const void* key, size_t nkey) {
+struct item* get_item(const void* key, size_t nkey)
+{
struct list_entry *walker= root;
struct list_entry *walker= root;
+
if (root == NULL)
{
return NULL;
if (root == NULL)
{
return NULL;
@@
-66,6
+73,7
@@
struct item* create_item(const void* key, size_t nkey, const void* data,
size_t size, uint32_t flags, time_t exp)
{
struct item* ret= calloc(1, sizeof(struct list_entry));
size_t size, uint32_t flags, time_t exp)
{
struct item* ret= calloc(1, sizeof(struct list_entry));
+
if (ret != NULL)
{
ret->key= malloc(nkey);
if (ret != NULL)
{
ret->key= malloc(nkey);
@@
-97,7
+105,8
@@
struct item* create_item(const void* key, size_t nkey, const void* data,
return ret;
}
return ret;
}
-bool delete_item(const void* key, size_t nkey) {
+bool delete_item(const void* key, size_t nkey)
+{
struct item* item= get_item(key, nkey);
bool ret= false;
struct item* item= get_item(key, nkey);
bool ret= false;
@@
-129,7
+138,8
@@
bool delete_item(const void* key, size_t nkey) {
return ret;
}
return ret;
}
-void flush(uint32_t when) {
+void flush(uint32_t when)
+{
/* FIXME */
(void)when;
/* remove the complete linked list */
/* FIXME */
(void)when;
/* remove the complete linked list */
@@
-150,10
+160,13
@@
void flush(uint32_t when) {
}
}
}
}
-void update_cas(struct item* item) {
+void update_cas(struct item* item)
+{
item->cas= ++cas;
}
item->cas= ++cas;
}
-void release_item(struct item* item __attribute__((unused))) {
+void release_item(struct item* item)
+{
+ (void)item;
/* EMPTY */
}
/* EMPTY */
}