//===#include ===#include ===#include // This is a line-oriented test driver for alloc.c. It's===#include ===#include ===#include // quick and dirty but it provides partial testing of===#include ===#include ===#include // of the alloc.c API via scripts of commands. One example========= // of a script is alloc1.1. Run it like this:===#include "/cs/www/classes/cs352/fall15/a11/alloc.h"===#include "/cs/www/classes/cs352/fall15/a11/alloc.h"===#include "/cs/www/classes/cs352/fall15/a11/alloc.h" //========= // alloc1 < alloc1.1===int main()===int main()===int main() //==={==={==={ === add_pool(3, 32); // Note: 3 blocks of 32 bytes=== char *p = alloc_block(3, "p");=== char *s1 = alloc_block(20, "s1"); #define _GNU_SOURCE=== add_pool(100, 1000);=== === printf("allocated: s1 = '%s'\n", s1); #include === add_pool(500, 256);=== check_blocks("After alloc_block:");=== strcpy(s1, "testing"); #include === === === printf("Before free: s1 = '%s'\n", s1); #include === char *p1 = alloc_block(1000, "A");=== strcpy(p, "abc");=== free_block(s1, "s1"); #include === p1 = alloc_block(100, "B");=== === printf("After free: s1 = '%s'\n", s1); #include === === check_blocks("After strcpy:");=== === for (int i = 1; i <= 5; i++) {=== === char **b = alloc_block(10 * sizeof(char*), "b"); #include "/cs/www/classes/cs352/fall15/a11/alloc.h"=== p1 = alloc_block(10, "C");=== int *ip = (int*)p;=== === p1 = p1; // avoid a "p1 unused" warning=== ip[-1] = 0;=== *b = "testing"; void dumpbytes(char *label, char *addr, int nbytes)=== }=== === free_block(b, "b"); {=== === check_blocks("After ip[-1] = 0:");=== printf("%s", label);=== show_pools("After allocations:");=== === printf("b = %lx\n", (unsigned long)*b); for (int i = 0; i < nbytes; i++) {===}=== show_pools("Pools:");===}