I wrote a reply to this but my computer overheated and crashed. I'm pretty sure 160°F is way too hot. So I cleaned the heatsink and left to find some thermal paste and forgot all about you.
#include <assert.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>typedef struct GLF_Entry{ int foobie;} GLF_Entry;typedef struct GLF_Font{ GLF_Entry *begin, *end, *alloc_end;} GLF_Font;GLF_Font * GLFcreate(void) { GLF_Font *font = malloc(sizeof(GLF_Font)); if(!font) return 0; if(!(font->end = font->begin = malloc(4*sizeof(GLF_Entry)))) { free(font); return 0; } font->alloc_end = font->begin+4; return font; }void GLFdestroy(GLF_Font *ptr) { assert(ptr); free(ptr->begin); free(ptr); }int GLFgetSize(GLF_Font *ptr) { assert(ptr); return ptr->end - ptr->begin; }GLF_Entry * GLFget(GLF_Font *ptr, int index) { assert(ptr); assert(index >= 0); assert(index < GLFgetSize(ptr)); return ptr->begin+index; }GLF_Entry * GLFgetNew(GLF_Font *ptr) { assert(ptr); if(ptr->end == ptr->alloc_end) { GLF_Entry *p = realloc(ptr->begin, (ptr->alloc_end-ptr->begin)*2*sizeof(GLF_Entry)); if(!p) return 0; ptr->end = ptr->end - ptr->begin + p; ptr->alloc_end = (ptr->alloc_end - ptr->begin) * 2 + p; ptr->begin = p; } GLF_Entry *n = ptr->end; ++(ptr->end); return n; }// Removes an element by copying all the elements ahead of it down one index.// Slow, but keeps the elements in order.void GLFremoveStable(GLF_Font *ptr, int index) { assert(ptr); assert(index >= 0); assert(index < GLFgetSize(ptr)); memmove(ptr->begin+index, ptr->begin+(index+1), (--(ptr->end)-(ptr->begin+index))*sizeof(GLF_Entry)); }// Removes an element quickly, buy moving the last element into the location of the deleted element.// Fast, but changes element ordering.void GLFremoveFast(GLF_Font *ptr, int index) { assert(ptr); assert(index >= 0); assert(index < GLFgetSize(ptr)); *(ptr->begin+index) = *(--(ptr->end)); }int main() { srand(time(0)); GLF_Font *font = GLFcreate(); int c; printf("Creating some elements. . .\n"); for(c = 0; c < 30; ++c) GLFgetNew(font)->foobie = c; printf("Contains %d elements.\n", GLFgetSize(font)); for(c = 0; c < GLFgetSize(font); ++c) printf("Element %d contains: %d\n", c, GLFget(font, c)->foobie); printf("Deleting some elements with GLFremoveStable. . .\n"); for(c = 0; c < 10; ++c) GLFremoveStable(font, rand()%GLFgetSize(font)); printf("Contains %d elements.\n", GLFgetSize(font)); for(c = 0; c < GLFgetSize(font); ++c) printf("Element %d contains: %d\n", c, GLFget(font, c)->foobie); printf("Deleting some elements with GLFremoveFast. . .\n"); for(c = 0; c < 10; ++c) GLFremoveFast(font, rand()%GLFgetSize(font)); printf("Contains %d elements.\n", GLFgetSize(font)); for(c = 0; c < GLFgetSize(font); ++c) printf("Element %d contains: %d\n", c, GLFget(font, c)->foobie); GLFdestroy(font); return 0; }
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.