/* Test allocations/desallocation memoire */ /* */ /* Auteur: Nicolas JANEY */ /* nicolas.janey@univ-fcomte.fr */ /* Mars 2019 */ #if defined(WIN32) || defined(WIN64) #define _CRTDBG_MAP_ALLOC #if defined(_DEBUG) #define _AFXDLL #include #endif #endif #include #if defined(WIN32) || defined(WIN64) #include #endif #include #include #include #include #include static char **t; /* Fonction executee lors d'un rafraichissement */ /* de la fenetre de dessin */ static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glutSwapBuffers(); int error = glGetError(); if ( error != GL_NO_ERROR ) printf("Erreur OpenGL: %d\n",error); } /* Fonction executee lors de la frappe */ /* d'une touche du clavier */ static void keyboard(unsigned char key,int x,int y) { switch ( key ) { case 0x1B : exit(0); break; } } static void clean() { } /* Fonction principale */ int main(int argc,char **argv) { #if defined(WIN32) || defined(WIN64) #if defined(_DEBUG) _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); _crtBreakAlloc = 120; #endif #endif atexit(clean); t =(char **) calloc(100,sizeof(char *)); for ( int i = 0 ; i < 100 ; i++ ) t[i] =(char *) malloc(1000); glutInit(&argc,argv); glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE); glutInitWindowSize(400,300); glutInitWindowPosition(50,50); glutCreateWindow("Test allocations/désallocation mémoire"); glutKeyboardFunc(keyboard); glutDisplayFunc(display); glutInitWindowPosition(250,100); glutMainLoop(); return(0); }