summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2016-09-15 09:42:51 +0200
committerantirez <antirez@gmail.com>2016-09-15 09:44:07 +0200
commitbf2624ea99ac92ae51db5453297aea4128692bad (patch)
tree4d5a46e592f4f61daa540838a9ac87e0b8bcfeda
parentbe5439bde3338fadaa5f84afbcc0078d0dbdb44d (diff)
downloadredis-bf2624ea99ac92ae51db5453297aea4128692bad.tar.gz
C struct memoh renamed redisMemOverhead. API prototypes added.
-rw-r--r--src/object.c33
-rw-r--r--src/server.h21
2 files changed, 28 insertions, 26 deletions
diff --git a/src/object.c b/src/object.c
index 8cf86235f..ddc49dfd0 100644
--- a/src/object.c
+++ b/src/object.c
@@ -853,40 +853,21 @@ void objectCommand(client *c) {
}
}
-/* This structure is returned by the getMemoryOverheadData() function in
- * order to return memory overhead information. */
-struct memoh {
- size_t total_allocated;
- size_t startup_allocated;
- size_t repl_backlog;
- size_t clients_slaves;
- size_t clients_normal;
- size_t aof_buffer;
- size_t overhead_total;
- size_t dataset;
- size_t num_dbs;
- struct {
- size_t dbid;
- size_t overhead_ht_main;
- size_t overhead_ht_expires;
- } *db;
-};
-
/* Release data obtained with getMemoryOverheadData(). */
-void freeMemoryOverheadData(struct memoh *mh) {
+void freeMemoryOverheadData(struct redisMemOverhead *mh) {
zfree(mh->db);
zfree(mh);
}
-/* Return a struct memoh filled with memory overhead information used
- * for the MEMORY OVERHEAD and INFO command. The returned structure
- * pointer should be freed calling freeMemoryOverheadData(). */
-struct memoh *getMemoryOverheadData(void) {
+/* Return a struct redisMemOverhead filled with memory overhead
+ * information used for the MEMORY OVERHEAD and INFO command. The returned
+ * structure pointer should be freed calling freeMemoryOverheadData(). */
+struct redisMemOverhead *getMemoryOverheadData(void) {
int j;
size_t mem_total = 0;
size_t mem = 0;
size_t zmalloc_used = zmalloc_used_memory();
- struct memoh *mh = zcalloc(sizeof(*mh));
+ struct redisMemOverhead *mh = zcalloc(sizeof(*mh));
mh->total_allocated = zmalloc_used;
mh->startup_allocated = server.initial_memory_usage;
@@ -982,7 +963,7 @@ void memoryCommand(client *c) {
usage += sizeof(dictEntry);
addReplyLongLong(c,usage);
} else if (!strcasecmp(c->argv[1]->ptr,"overhead") && c->argc == 2) {
- struct memoh *mh = getMemoryOverheadData();
+ struct redisMemOverhead *mh = getMemoryOverheadData();
addReplyMultiBulkLen(c,(8+mh->num_dbs)*2);
diff --git a/src/server.h b/src/server.h
index 0d104425c..fb094507b 100644
--- a/src/server.h
+++ b/src/server.h
@@ -769,6 +769,25 @@ typedef struct redisOpArray {
int numops;
} redisOpArray;
+/* This structure is returned by the getMemoryOverheadData() function in
+ * order to return memory overhead information. */
+struct redisMemOverhead {
+ size_t total_allocated;
+ size_t startup_allocated;
+ size_t repl_backlog;
+ size_t clients_slaves;
+ size_t clients_normal;
+ size_t aof_buffer;
+ size_t overhead_total;
+ size_t dataset;
+ size_t num_dbs;
+ struct {
+ size_t dbid;
+ size_t overhead_ht_main;
+ size_t overhead_ht_expires;
+ } *db;
+};
+
/*-----------------------------------------------------------------------------
* Global server state
*----------------------------------------------------------------------------*/
@@ -1481,6 +1500,8 @@ void updateCachedTime(void);
void resetServerStats(void);
unsigned int getLRUClock(void);
const char *evictPolicyToString(void);
+struct redisMemOverhead *getMemoryOverheadData(void);
+void freeMemoryOverheadData(struct redisMemOverhead *mh);
#define RESTART_SERVER_NONE 0
#define RESTART_SERVER_GRACEFULLY (1<<0) /* Do proper shutdown. */