From bf2624ea99ac92ae51db5453297aea4128692bad Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 15 Sep 2016 09:42:51 +0200 Subject: [PATCH] C struct memoh renamed redisMemOverhead. API prototypes added. --- src/object.c | 33 +++++++-------------------------- src/server.h | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/object.c b/src/object.c index 8cf86235..ddc49dfd 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 0d104425..fb094507 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. */