Skip to content

Commit

Permalink
use the function deprecated attribute if compiling with GCC to get wa…
Browse files Browse the repository at this point in the history
…rnings for malloc/free usages. We always want to use our zmalloc/zfree versions for memory usage tracking
  • Loading branch information
antirez committed Jul 27, 2010
1 parent 399f2f4 commit b3aa6d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ int qsortRedisCommands(const void *r1, const void *r2) {

void sortCommandTable() {
/* Copy and sort the read-only version of the command table */
commandTable = (struct redisCommand*)malloc(sizeof(readonlyCommandTable));
commandTable = (struct redisCommand*)zmalloc(sizeof(readonlyCommandTable));
memcpy(commandTable,readonlyCommandTable,sizeof(readonlyCommandTable));
qsort(commandTable,
sizeof(readonlyCommandTable)/sizeof(struct redisCommand),
Expand Down
8 changes: 8 additions & 0 deletions src/redis.h
Original file line number Diff line number Diff line change
Expand Up @@ -885,4 +885,12 @@ void publishCommand(redisClient *c);
void watchCommand(redisClient *c);
void unwatchCommand(redisClient *c);

#if defined(__GNUC__)
void *malloc(size_t size) __attribute__ ((deprecated));
void *calloc(size_t count, size_t size) __attribute__ ((deprecated));
void free(void *ptr) __attribute__ ((deprecated));
void *malloc(size_t size) __attribute__ ((deprecated));

This comment has been minimized.

Copy link
@dubek

dubek Jul 27, 2010

why define malloc twice? (see line 889)

This comment has been minimized.

Copy link
@antirez

antirez Jul 27, 2010

Author Contributor

It's a typo indeed, thanks, removing the duplication

void *realloc(void *ptr, size_t size) __attribute__ ((deprecated));
#endif

#endif

0 comments on commit b3aa6d7

Please sign in to comment.