+static int qsortRedisCommands(const void *r1, const void *r2) {
+ return strcasecmp(
+ ((struct redisCommand*)r1)->name,
+ ((struct redisCommand*)r2)->name);
+}
+
+static void sortCommandTable() {
+ int i = 0, size = 0;
+
+ /* Determine and store the size of the command table */
+ while(readonlyCommandTable[i++].name != NULL) size++;
+ commandTableSize = size;
+
+ /* Copy and sort the read-only version of the command table */
+ commandTable = (struct redisCommand*)malloc(sizeof(readonlyCommandTable));
+ memcpy(commandTable,readonlyCommandTable,sizeof(readonlyCommandTable));
+ qsort(commandTable,size,sizeof(struct redisCommand),qsortRedisCommands);
+}
+