Mercurial > sos > sos
view src/dynamic.c @ 97:917b70f168b0
Some minor bug fixes
string.h now defines __STRING_H
Removed unneeded operations.h from dynamic test program
Added string.h header to the filesystem, needed for memcpy
The code for deleting files now copies the correct direntry
Removed a duplicate line from the filesystem test prompt
author | Jonathan Pevarnek <pevarnj@gmail.com> |
---|---|
date | Sat, 14 May 2011 16:47:35 -0400 |
parents | 191e99dffd6c |
children | 14d96c95dd56 |
line wrap: on
line source
/* * This is where everything starts */ #include <std.h> #include <string.h> #include <stack.h> void dumpBuffer(char *a, int b) { int i; for(i = 0; i < b; i++) { int foo = (int) a[i]; char c[10]; itoa(foo, c, 16); sPrint(c); sPrint(" "); if(!((i + 1)%20)) sPrint("\n"); } } void start(u64 __memsize) { init_all(__memsize); size_t n; char *buffer; char input[30]; while(0) { sPrint("How long do you want the string? "); n = atoi(sGet(input, 30)); buffer = (char*) malloc(n); if (!buffer) { //allocation failed, too large sPrint("ERROR\n"); break; } // size_t i; // for (i = 0; i < n - 1; i++) // buffer[i]='a'; //I need to make rand... // buffer[n - 1]='\0'; // sPrint(buffer), sPrint("\n"); // dumpBuffer(buffer, n); sPrint(strcat(itoa((unsigned long)buffer, input, 16), "\n")); free(buffer); } printMem(); Stack *stack = stack_init(); for(n = 0; n < 1000; n++) { push(stack, n); } stack_destroy(stack); printMem(); void *a = malloc(1223); void *b = malloc(352); void *c = malloc(3539); void *d = malloc(325); printMem(); free(b); printMem(); b = malloc(400); printMem(); sPrint("DONE\n"); free(a); free(c); free(d); for(;;) sGet(input, 0); }