fork download
  1. #include <stdlib.h>
  2. #include <memory.h>
  3. #include <stddef.h>
  4. #include <stdbool.h>
  5.  
  6. //MIT Lisece
  7. //2019 Yakitori.
  8.  
  9. typedef struct Memory_ {
  10. void* Memory;
  11. size_t ElementSize;
  12. size_t Length;
  13. } Memory;
  14.  
  15. Memory MemoryAllocate(size_t N,size_t SizeOfElement ) {
  16. Memory M = { NULL,0 ,0};
  17.  
  18. M.Memory = malloc(N*SizeOfElement);
  19.  
  20. if (M.Memory != NULL) {
  21. memset(M.Memory, 0, N*SizeOfElement);
  22. M.Length = N;
  23. M.ElementSize = SizeOfElement;
  24. }
  25.  
  26. return M;
  27. }
  28.  
  29. Memory MemoryReAllocate(Memory* Mem,size_t N) {
  30. Memory M = { NULL,0 ,0};
  31.  
  32. void *p = realloc(Mem->Memory,N*Mem->ElementSize);
  33.  
  34. if (p != NULL) {
  35. if (p != Mem->Memory) { free(Mem->Memory); }
  36. Mem->Memory = p;
  37. M.Length = N;
  38. }
  39.  
  40. return M;
  41. }
  42.  
  43. bool MemoryFree(Memory* In) {
  44. free(In->Memory);
  45.  
  46. In->Memory = NULL;
  47. In->Length = 0;
  48. In->ElementSize = 0;
  49. return true;
  50. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty