Commits

Roma Sokolov committed 2d29905

mem test

  • Participants
  • Parent commits fe8bd3e

Comments (0)

Files changed (1)

File memorytest/memtest.c

+#include <stdio.h>
+
+typedef struct _nm {
+  int x;
+  int y;
+  long z;
+  char b[24];
+  char buffer[1];
+} NM;
+
+int main(){
+  char * chptr;
+  char chr;
+  int i;
+  int * array;
+  NM * data;
+
+  printf("Sizeof charptr -- %lu; char -- %lu; int -- %lu \n",
+         sizeof(chptr), sizeof(chr), sizeof(i));
+  while (1) {
+    chr = getchar();
+    switch (chr) {
+    case 'a':
+      data = (NM*)malloc(sizeof(char) * 1000 * 1000 * 50);
+      printf("Sizeof ptr: %lu; data -- %lu ; \n", sizeof(data), sizeof(*data));
+      break;
+    case 'd':
+      free(data);
+      break;
+    case 'e':
+      return 0;
+    }
+  }
+
+  return 0;
+}