is this niggerlicious?
#include <stdio.h>
#include <stdlib.h>
struct client {
char name[16];
bool active;
static client *zero() {
static client client_zero;
return &client_zero;
}
void *operator new(unsigned long sz);
void print();
};
const size_t max_clients = 100;
static size_t next_client_id = 0;
static client client_pool[max_clients];
void *client::operator new(unsigned long sz) {
printf("nigger\n");
if (next_client_id >= max_clients) {
return client::zero();
}
return &client_pool[next_client_id++];
}
void client::print() {
if (this->active) {
printf("this is %s\n", this->name);
} else {
printf("inactive\n");
}
}
void print_all_clients() {
for (size_t id = 0; id < next_client_id; id++) {
client_pool[id].print();
}
}
int main() {
client *steve = new client{.name = "steve", .active = true};
client *bob = new client{.name = "bob", .active = true};
client *andrea = new client{.name = "andrea", .active = true};
print_all_clients();
bob->active = false;
print_all_clients();
return 0;
}
// compile with: g++ -nostdinc++