Memory Error.c 768 B

12345678910111213141516171819202122232425262728293031
  1. // Allocate memory as long as possible, then throw an error
  2. // All allocated memory will be freed again!
  3. #define USE_TI89 // Compile for TI-89
  4. #define USE_TI92PLUS // Compile for TI-92 Plus
  5. #define USE_V200 // Compile for V200
  6. #define MIN_AMS 100 // Compile for AMS 1.00 or higher
  7. #define ENABLE_ERROR_RETURN // Enable Returning Errors to TIOS
  8. #include <tigcclib.h> // Include All Header Files
  9. #define BLOCK_SIZE 1024
  10. void AllocRecursively(void)
  11. {
  12. void *ptr = malloc_throw (BLOCK_SIZE);
  13. TRY
  14. // Could do something with ptr here...
  15. AllocRecursively ();
  16. // Could still do something with ptr...
  17. FINALLY
  18. free (ptr);
  19. ENDFINAL
  20. }
  21. // Main Function
  22. void _main(void)
  23. {
  24. AllocRecursively ();
  25. }