This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct { | |
unsigned int size; /* sizes of items */ | |
unsigned int perslab; /* how many items per slab */ | |
void *slots; /* list of item ptrs */ | |
unsigned int sl_curr; /* total free items in list */ | |
unsigned int slabs; /* how many slabs were allocated for this class */ | |
void **slab_list; /* array of slab pointers */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case 'I': | |
buf = strdup(optarg); | |
unit = buf[strlen(buf)-1]; | |
if (unit == 'k' || unit == 'm' || | |
unit == 'K' || unit == 'M') { | |
buf[strlen(buf)-1] = '\0'; | |
size_max = atoi(buf); | |
if (unit == 'k' || unit == 'K') | |
size_max *= 1024; | |
if (unit == 'm' || unit == 'M') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void slabs_init(const size_t limit, const double factor, const bool prealloc, const uint32_t *slab_sizes) { | |
int i = POWER_SMALLEST /* scr: 1 */ - 1; | |
unsigned int size = sizeof(item) + settings.chunk_size; // scr: ---------> b 1) | |
... | |
memset(slabclass, 0, sizeof(slabclass)); | |
while (++i < MAX_NUMBER_OF_SLAB_CLASSES-1) { | |
if (slab_sizes != NULL) { // scr: -----------------------------------> a 1) | |
if (slab_sizes[i-1] == 0) | |
break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… | |
case 'f': | |
settings.factor = atof(optarg); | |
if (settings.factor <= 1.0) { | |
fprintf(stderr, "Factor must be greater than 1\n"); | |
return 1; | |
} | |
break; | |
… | |
case 'o': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… | |
assoc_init(settings.hashpower_init); | |
conn_init(); | |
slabs_init(settings.maxbytes, settings.factor, preallocate, | |
use_slab_sizes ? slab_sizes : NULL); | |
… |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
...include | |
#define BUF_SIZE 256 | |
int main(int argc, char *argv[]) | |
{ | |
int sfd, rfd, portno, clilen; | |
char buffer[BUF_SIZE]; | |
struct sockaddr_in serv_addr, cli_addr; | |
int n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
...include | |
int main(int argc, char *argv[]) { | |
int sfd, portno, n, delay; | |
struct sockaddr_in srvaddr; | |
struct hostent *host; | |
char buffer[256] = "abc"; | |
if (argc < 3) { fprintf(stderr,"usage: %s ip port delay\n", argv[0]); exit(0); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
...include | |
int main(int argc, char *argv[]) { | |
int sfd, portno, n; | |
struct sockaddr_in srvaddr; | |
struct hostent *host; | |
if (argc < 3) { fprintf(stderr,"usage: %s ip port\n", argv[0]); exit(0); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
...include | |
#define BUF_SIZE 256 | |
int main(int argc, char *argv[]) | |
{ | |
int sfd, rfd, portno, clilen; | |
char buffer[BUF_SIZE]; | |
struct sockaddr_in serv_addr, cli_addr; | |
int n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…include | |
int main(int argc, char *argv[]) { | |
int sfd, portno, n; | |
struct sockaddr_in srvaddr; | |
struct hostent *host; | |
if (argc < 3) { fprintf(stderr,"usage: %s ip port\n", argv[0]); exit(0); } | |
portno = atoi(argv[2]); |