BABYL OPTIONS: -*- rmail -*- Version: 5 Labels: Note: This is the header of an rmail file. Note: If you are seeing it in rmail, Note: it means the file has no messages in it.  1,, Summary-line: 15-Dec michenea #purify gqueue Mail-from: From michenea Fri Dec 15 09:45:30 1995 Return-Path: Received: from gedeon.labri.u-bordeaux.fr.labri by victor.labri.u-bordeaux.fr (4.1/SM-mailhost-BORDEAUX-1.0) id AA01391; Fri, 15 Dec 95 09:45:29 +0100 Date: Fri, 15 Dec 95 09:45:29 +0100 From: michenea (Cyrille MICHENEAU) Message-Id: <9512150845.AA01391@victor.labri.u-bordeaux.fr> To: strandh Subject: purify gqueue *** EOOH *** Return-Path: Date: Fri, 15 Dec 95 09:45:29 +0100 From: michenea (Cyrille MICHENEAU) To: strandh Subject: purify gqueue Bonjour, apres avoir lance purify sur conrad, j'ai eu des messages fort peu sympatiques : j'utilise les bibliotheques hash et gqueue. hash fonctionne bien, mais gqueue...Je cree les gqueue avec gq_create. Lorsque je fais gq_add, il me dit que j'ai un uninitialized memory read dans la fonction gq_push_cursor... C'est grave docteur ? a+. Cyrille. ----------------------------------------- **** Purify'd conrad (pid 15817) **** Purify (umr): uninitialized memory read: * This is occurring while in: gq_push_cursor [line 127, gqueue.c, pc=0x3a000] gq_add [line 205, gqueue.c, pc=0x3a670] conradparse [line 161, conrad.y, pc=0x1ef34] parse_algo_file [line 80, main.c, pc=0x2e2a0] main_function [line 127, main.c, pc=0x2e840] main [line 135, main.c, pc=0x2e9f0] * Reading 4 bytes from 0x1d78ad4 in the heap. * This is 4 bytes into a malloc'd block at 0x1d78ad0 of 16 bytes. * This block was allocated from: malloc [p6.o, pc=0x46d4] gq_create_aux [line 151, gqueue.c, pc=0x3a1f4] gq_create [line 175, gqueue.c, pc=0x3a464] conradparse [line 160, conrad.y, pc=0x1ef10] parse_algo_file [line 80, main.c, pc=0x2e2a0] main_function [line 127, main.c, pc=0x2e840]  1,, Mail-from: From Angel-Ventura.Mendo.Gomez@emi.u-bordeaux.fr Sat Mar 16 19:02:17 1996 Return-Path: Received: from aliboron.emi.u-bordeaux.fr by victor.labri.u-bordeaux.fr (4.1/SM-mailhost-BORDEAUX-1.0) id AA21170; Sat, 16 Mar 96 19:02:16 +0100 Received: from harold.emi.u-bordeaux.fr by aliboron.emi.u-bordeaux.fr; Sat, 16 Mar 1996 18:59:34 +0100 Received: by harold.emi.u-bordeaux.fr; Sat, 16 Mar 1996 18:57:11 +0100 Date: Sat, 16 Mar 1996 18:57:11 +0100 Message-Id: <199603161757.SAA13059@harold.emi.u-bordeaux.fr> From: Angel-Ventura Mendo Gomez To: strandh@labri.u-bordeaux.fr Cc: gomez puleggi liegeois@emi.u-bordeaux.fr Subject: Modifications du module gqueue *** EOOH *** Return-Path: Date: Sat, 16 Mar 1996 18:57:11 +0100 From: Angel-Ventura Mendo Gomez To: strandh@labri.u-bordeaux.fr Cc: gomez puleggi liegeois@emi.u-bordeaux.fr Subject: Modifications du module gqueue nous allons utiliser votre module "gqueue" dans notre projet "Animation de une scène 3D" dirigé par Mmw Gueorguieva, et nous demandons votre autorisation pour faire quelques modifications: a) ajouter à la structure gqueue_structure un champ int (*equal)(void *,void *); pour tester l'égalité entre deux éléments de la gqueue b) Utilisation du module "mem" donné en cours de MTP pour la gestion de l'allocation dynamique de la mémoire c) Utilisation du module "exception" donné en cours de MTP, avec quelques modifications, pour la gestion des erreurs Maintenant je vous envoie par mail le contenu des fichiers: gqueue_bis.h et gqueue_bis.c, avec les modifications a votre code source original mem.h mem.c exception.h exception.c En vous remerciant pour votre attention: /-------------------------------------- E=mc^2 | Angel-Ventura Mendo Gomez \ | ventura@emi.u-bordeaux.fr \ (define (E m c) | ventura@roble.usal.es \ (* m (* c c)) \ http://www.emi.u-bordeaux.fr/~ventura \ ) ------------------------------------------  1,, Mail-from: From Angel-Ventura.Mendo.Gomez@emi.u-bordeaux.fr Sat Mar 16 19:04:17 1996 Return-Path: Received: from aliboron.emi.u-bordeaux.fr by victor.labri.u-bordeaux.fr (4.1/SM-mailhost-BORDEAUX-1.0) id AA21177; Sat, 16 Mar 96 19:04:17 +0100 Received: from harold.emi.u-bordeaux.fr by aliboron.emi.u-bordeaux.fr; Sat, 16 Mar 1996 19:01:35 +0100 Received: by harold.emi.u-bordeaux.fr; Sat, 16 Mar 1996 18:59:12 +0100 Date: Sat, 16 Mar 1996 18:59:12 +0100 Message-Id: <199603161759.SAA13085@harold.emi.u-bordeaux.fr> From: Angel-Ventura Mendo Gomez To: strandh@labri.u-bordeaux.fr Cc: gomez puleggi liegeois@emi.u-bordeaux.fr Subject: gqueue_bis.h *** EOOH *** Return-Path: Date: Sat, 16 Mar 1996 18:59:12 +0100 From: Angel-Ventura Mendo Gomez To: strandh@labri.u-bordeaux.fr Cc: gomez puleggi liegeois@emi.u-bordeaux.fr Subject: gqueue_bis.h /* * File: gqueue_bis.h * * $Id: gqueue_bis.h,v 1.3 1996/03/16 17:05:16 ventura Exp $ */ /* File: queue.h Author: Robert Strandh Purpose: Header file for double ended queue package. $Id: gqueue_bis.h,v 1.3 1996/03/16 17:05:16 ventura Exp $ */ #ifndef _GQ_PACKAGE_BIS /* data structures */ struct gq_cell_structure { char *element; struct gq_cell_structure *prev; struct gq_cell_structure *next; }; typedef struct gq_cell_structure *gq_cell; typedef struct gqueue_structure *gqueue; struct gqueue_structure { gq_cell head; gq_cell tail; gq_cell cursor; gqueue cursor_save; void (*element_destroy)(); int (*equal)(void *,void *); }; /* * Exceptions Management */ #include USE_EXCEPTION (end_list_reached_EXCEPTION); USE_EXCEPTION (begin_list_reached_EXCEPTION); USE_EXCEPTION (empty_list_EXCEPTION); /* The queue uses the concept of a cursor. A cursor works like the emacs dot, i.e. it is located between two element, before the first element, or after the last element. Every queue has a cursor stack. The top of the stack is the cursor used by the queue operations. We call it the current cursor. */ /* create an empty queue */ extern gqueue gq_create(); /* check whether queue is empty */ extern int gq_empty(gqueue); /* destroy the queue */ extern void gq_destroy(gqueue); /* set the destroy function for individual elements */ extern void gq_set_destroy(gqueue, void (*)()); /* *set the equal function */ extern void gq_set_equal(gqueue, int (*)(void *,void *)); /* functions to position the current cursor */ /* position current cursor before the first element */ extern void gq_go_beginning(gqueue); /* position current cursor after the last element */ extern void gq_go_end(gqueue); /* move current cursor forward */ extern void gq_go_forward(gqueue); /* move current cursor backward */ extern void gq_go_backward(gqueue); /* functions for checking where the current cursor is located */ /* check if current cursor is located before the first element */ extern int gq_at_beginning(gqueue); /* check if current cursor is located after the last element */ extern int gq_at_end(gqueue); /* get element after current cursor without moving current cursor */ extern void *gq_get(gqueue); /* get first element of queue without moving current cursor */ extern void *gq_get_first(gqueue); /* functions for insertion and deletion of elements */ /* insert an element after current cursor and position the curren cursor after the newly inserted element */ extern void gq_insert(gqueue, void *); /* delete element after the current cursor */ extern void gq_delete(gqueue); /* replace the element after the current cursor */ extern void gq_replace(gqueue, void *); /* functions for manipulating the cursor stack */ /* push old cursor and create a new current cursor with undefined value */ extern void gq_push_cursor(gqueue); /* pop the cursor stack replacing the current cursor with value pushed */ extern void gq_pop_cursor(gqueue); extern gqueue gq_copy(gqueue); extern void gq_make_empty(gqueue q); extern int gq_member(gqueue q, void *elem); extern void gq_add(gqueue q, void *elem); extern void gq_subtract(gqueue q, void *elem); /*put the non repetitive union of the 2 queue in q. For example if an element*/ /*of r is already in q, no addition is made. The r queue is never modified*/ extern void gq_union(gqueue q, gqueue r); extern void gq_intersection(gqueue q, gqueue r); extern void gq_concat(gqueue q, gqueue r); #define _GQ_PACKAGE_BIS #endif /* _GQ_PACKAGE_BIS */  1,, Mail-from: From Angel-Ventura.Mendo.Gomez@emi.u-bordeaux.fr Sat Mar 16 19:04:47 1996 Return-Path: Received: from aliboron.emi.u-bordeaux.fr by victor.labri.u-bordeaux.fr (4.1/SM-mailhost-BORDEAUX-1.0) id AA21183; Sat, 16 Mar 96 19:04:46 +0100 Received: from harold.emi.u-bordeaux.fr by aliboron.emi.u-bordeaux.fr; Sat, 16 Mar 1996 19:02:05 +0100 Received: by harold.emi.u-bordeaux.fr; Sat, 16 Mar 1996 18:59:42 +0100 Date: Sat, 16 Mar 1996 18:59:42 +0100 Message-Id: <199603161759.SAA13087@harold.emi.u-bordeaux.fr> From: Angel-Ventura Mendo Gomez To: strandh@labri.u-bordeaux.fr Cc: gomez puleggi liegeois@emi.u-bordeaux.fr Subject: gqueue_bis.c *** EOOH *** Return-Path: Date: Sat, 16 Mar 1996 18:59:42 +0100 From: Angel-Ventura Mendo Gomez To: strandh@labri.u-bordeaux.fr Cc: gomez puleggi liegeois@emi.u-bordeaux.fr Subject: gqueue_bis.c /* * File: gqueue_bis.c * * $Id: gqueue_bis.c,v 1.3 1996/03/16 17:04:57 ventura Exp $ */ /* File: gqueue.c Author: Robert Strandh Purpose: Generalized queue (well, list) package. $Id: gqueue_bis.c,v 1.3 1996/03/16 17:04:57 ventura Exp $ */ static char rcsid[] = "$Id: gqueue_bis.c,v 1.3 1996/03/16 17:04:57 ventura Exp $"; #include #include #include "gqueue_bis.h" DEFINE_EXCEPTION (end_list_reached_EXCEPTION); DEFINE_EXCEPTION (begin_list_reached_EXCEPTION); DEFINE_EXCEPTION (empty_list_EXCEPTION); #define ELEMENT void * void gq_go_beginning(gqueue q) { q -> cursor = q -> head;} void gq_go_end(gqueue q) { q -> cursor = q -> tail -> prev;} int gq_at_beginning(gqueue q) { return q -> cursor == q -> head;} int gq_at_end(gqueue q) { return q -> cursor == q -> tail -> prev;} int gq_empty(gqueue q) { return q -> head -> next == q -> tail;} void gq_go_forward(gqueue q) { if(gq_at_end(q)) RAISE(end_list_reached_EXCEPTION); q -> cursor = q -> cursor -> next; } void gq_go_backward(gqueue q) { if(gq_at_beginning(q)) RAISE(begin_list_reached_EXCEPTION); q -> cursor = q -> cursor -> prev; } void * gq_get(gqueue q) { if (gq_at_end(q)) RAISE(end_list_reached_EXCEPTION); return q -> cursor -> next -> element; } void * gq_get_first(gqueue q) { if(gq_empty(q)) RAISE(empty_list_EXCEPTION); return q -> head -> next -> element; } void gq_insert(gqueue q, void *element) { gq_cell temp = (gq_cell) mem_alloc(sizeof(struct gq_cell_structure)); temp -> element = element; temp -> next = q -> cursor -> next; temp -> prev = q -> cursor; q -> cursor -> next -> prev = temp; q -> cursor -> next = temp; q -> cursor = temp; } void gq_delete(gqueue q) { gq_cell temp; if(gq_at_end(q)) RAISE(end_list_reached_EXCEPTION); temp = q -> cursor -> next; temp -> next -> prev = temp -> prev; temp -> prev -> next = temp -> next; (*(q -> element_destroy))(temp -> element); mem_free(temp); } void gq_replace(gqueue q, void *element) { gq_cell temp; if(gq_at_end(q)) RAISE(end_list_reached_EXCEPTION); temp = q -> cursor -> next; (*(q -> element_destroy))(temp -> element); temp -> element = element; } void gq_destroy(q) gqueue q; { gq_go_beginning(q); while(!gq_empty(q)) { gq_delete(q); } mem_free(q->head); mem_free(q->tail); mem_free(q); } void gq_set_destroy(gqueue q,void (*destroy)()) { q -> element_destroy = destroy; } /* * begin modification */ void gq_set_equal(gqueue q,int (*equal)(void *,void *)) { q -> equal= equal; } /* * end modification */ void gq_push_cursor(gqueue q) { gq_insert(q -> cursor_save, q -> cursor); gq_go_beginning(q -> cursor_save); q -> cursor = q -> head; } void gq_pop_cursor(gqueue q) { q -> cursor = gq_get(q -> cursor_save); gq_delete(q -> cursor_save); } static void dummy_destroy(void *element) { /* do nothing */ } /* * begin modification */ static int default_equal(void *r,void *s) { if (r==s) return 1; else return 0; } /* * end mofification */ static gqueue gq_create_aux() { gqueue temp; temp = (gqueue) mem_alloc(sizeof(struct gqueue_structure)); temp -> element_destroy = dummy_destroy; temp -> equal = default_equal; temp -> head = (gq_cell) mem_alloc(sizeof(struct gq_cell_structure)); temp -> tail = (gq_cell) mem_alloc(sizeof(struct gq_cell_structure)); temp -> cursor = temp -> head; temp -> head -> next = temp -> tail; temp -> tail -> prev = temp -> head; return(temp); } gqueue gq_copy(gqueue q) { gqueue temp = gq_create(); gq_push_cursor(q); for(gq_go_beginning(q); !gq_at_end(q); gq_go_forward(q)) { gq_insert(temp, gq_get(q)); } gq_pop_cursor(q); return temp; } gqueue gq_create() { gqueue temp = gq_create_aux(); temp -> cursor_save = gq_create_aux(); return temp; } void gq_make_empty(gqueue q) { for(gq_go_beginning(q); !gq_empty(q); ) { gq_delete(q); } } int gq_member(gqueue q, void *elem) { gq_push_cursor(q); for(gq_go_beginning(q); !gq_at_end(q); gq_go_forward(q)) { /* * modification * * if(gq_get(q) == elem) * return 1; */ if ( (*(q->equal))(gq_get(q),elem) ) return 1; } gq_pop_cursor(q); return 0; } void gq_add(gqueue q, void *elem) { gq_push_cursor(q); for(gq_go_beginning(q); !gq_at_end(q); gq_go_forward(q)) { /* * modification * * if(gq_get(q) == elem) * break; */ if ( (*(q->equal))(gq_get(q),elem) ) break; } if(gq_at_end(q)) gq_insert(q, elem); gq_pop_cursor(q); } void gq_subtract(gqueue q, void *elem) { gq_push_cursor(q); for(gq_go_beginning(q); !gq_at_end(q); gq_go_forward(q)) { /* * Modification * * if(gq_get(q) == elem) */ if ( (*(q->equal))(gq_get(q),elem) ) { gq_delete(q); break; } } gq_pop_cursor(q); } void gq_union(gqueue q, gqueue r) { gq_push_cursor(r); for(gq_go_beginning(r); !gq_at_end(r); gq_go_forward(r)) { gq_add(q, gq_get(r)); } gq_pop_cursor(r); } void gq_intersection(gqueue q, gqueue r) { gq_push_cursor(r); for(gq_go_beginning(r); !gq_at_end(r); gq_go_forward(r)) { gq_subtract(q, gq_get(r)); } gq_pop_cursor(r); } void gq_concat(gqueue q, gqueue r) { gq_push_cursor(q); gq_go_end(q); gq_push_cursor(r); for(gq_go_beginning(r); !gq_at_end(r); gq_go_forward(r)) { gq_insert(q, gq_get(r)); } gq_pop_cursor(r); gq_pop_cursor(q); } void gq_map(gqueue q, void (*fun)(void *)) { gq_push_cursor(q); for(gq_go_beginning(q); !gq_at_end(q); gq_go_forward(q)) { fun(gq_get(q)); } gq_pop_cursor(q); }  1,, Mail-from: From Angel-Ventura.Mendo.Gomez@emi.u-bordeaux.fr Sat Mar 16 19:08:05 1996 Return-Path: Received: from aliboron.emi.u-bordeaux.fr by victor.labri.u-bordeaux.fr (4.1/SM-mailhost-BORDEAUX-1.0) id AA21203; Sat, 16 Mar 96 19:08:04 +0100 Received: from harold.emi.u-bordeaux.fr by aliboron.emi.u-bordeaux.fr; Sat, 16 Mar 1996 19:05:22 +0100 Received: by harold.emi.u-bordeaux.fr; Sat, 16 Mar 1996 19:03:00 +0100 Date: Sat, 16 Mar 1996 19:03:00 +0100 Message-Id: <199603161803.TAA13122@harold.emi.u-bordeaux.fr> From: Angel-Ventura Mendo Gomez To: strandh@labri.u-bordeaux.fr Cc: gomez puleggi liegeois@emi.u-bordeaux.fr Subject: mem.h *** EOOH *** Return-Path: Date: Sat, 16 Mar 1996 19:03:00 +0100 From: Angel-Ventura Mendo Gomez To: strandh@labri.u-bordeaux.fr Cc: gomez puleggi liegeois@emi.u-bordeaux.fr Subject: mem.h /* * File: mem.h * Author: Angel-Ventura Mendo Gomez * Purpose: * Module for the dynamical memory management * * $Id: mem.h,v 1.2 1996/03/16 17:04:08 ventura Exp ventura $ */ #ifndef _MEM_H_ #define _MEM_H_ #include #include USE_EXCEPTION(mem_default_EXCEPTION); /* * Memory gestion functions */ extern void *mem_alloc(size_t size); extern void *mem_calloc(size_t , size_t); extern void *mem_realloc(void * , size_t); extern void mem_free(void *p); /* * Set the functions of the module. * if the user function == NULL * on set the default function */ extern void mem_set_functions(void *(*malloc_user_fun)(size_t), void (*free_user_fun)(void *), void *(*calloc_user_fun)(size_t,size_t), void *(*realloc_user_fun)(void *,size_t)); /* * Set de default functions: * malloc, calloc, realloc, free. */ extern void mem_set_default_functions(void); #endif /* _MEM_H_ */  1,, Mail-from: From Angel-Ventura.Mendo.Gomez@emi.u-bordeaux.fr Sat Mar 16 19:08:42 1996 Return-Path: Received: from aliboron.emi.u-bordeaux.fr by victor.labri.u-bordeaux.fr (4.1/SM-mailhost-BORDEAUX-1.0) id AA21209; Sat, 16 Mar 96 19:08:41 +0100 Received: from harold.emi.u-bordeaux.fr by aliboron.emi.u-bordeaux.fr; Sat, 16 Mar 1996 19:06:00 +0100 Received: by harold.emi.u-bordeaux.fr; Sat, 16 Mar 1996 19:03:37 +0100 Date: Sat, 16 Mar 1996 19:03:37 +0100 Message-Id: <199603161803.TAA13138@harold.emi.u-bordeaux.fr> From: Angel-Ventura Mendo Gomez To: strandh@labri.u-bordeaux.fr Cc: gomez puleggi liegeois@emi.u-bordeaux.fr Subject: mem.c *** EOOH *** Return-Path: Date: Sat, 16 Mar 1996 19:03:37 +0100 From: Angel-Ventura Mendo Gomez To: strandh@labri.u-bordeaux.fr Cc: gomez puleggi liegeois@emi.u-bordeaux.fr Subject: mem.c /* * File: mem.c * Author: Angel-Ventura Mendo Gomez * Purpose: * Module for the dynamical memory management * * $Id: mem.c,v 1.1 1996/03/16 16:03:53 ventura Exp ventura $ */ #include #include "mem.h" static void *(*malloc_fun)(size_t)= malloc; static void *(*calloc_fun)(size_t, size_t)= calloc; static void *(*realloc_fun)(void *, size_t)= realloc; static void (*free_fun)(void *)= free; DEFINE_EXCEPTION (mem_default_EXCEPTION); void *mem_alloc(size_t size) { void *p = malloc_fun(size); if (p==NULL) RAISE(mem_default_EXCEPTION); return p; } void *mem_calloc(size_t number, size_t size) { void *p=calloc_fun(number,size); if (p==NULL) RAISE(mem_default_EXCEPTION); return p; } void *mem_realloc(void *ptr, size_t size) { void *p=realloc_fun(ptr,size); if (p==NULL) RAISE(mem_default_EXCEPTION); return p; } void mem_free(void *p) { free_fun(p); } void mem_set_functions(void *(*malloc_user_fun)(size_t), void (*free_user_fun)(void*), void *(*calloc_user_fun)(size_t,size_t), void *(*realloc_user_fun)(void *,size_t)) { if (malloc_user_fun!=NULL) malloc_fun=malloc_user_fun; if (calloc_user_fun!=NULL) calloc_fun=calloc_user_fun; if (realloc_user_fun!=NULL) realloc_fun=realloc_user_fun; if (free_user_fun!=NULL) free_fun=free_user_fun; } void mem_set_default_functions(void) { malloc_fun= malloc; calloc_fun= calloc; realloc_fun= realloc; free_fun = free; }  1,, Mail-from: From Angel-Ventura.Mendo.Gomez@emi.u-bordeaux.fr Sat Mar 16 19:09:17 1996 Return-Path: Received: from aliboron.emi.u-bordeaux.fr by victor.labri.u-bordeaux.fr (4.1/SM-mailhost-BORDEAUX-1.0) id AA21213; Sat, 16 Mar 96 19:09:16 +0100 Received: from harold.emi.u-bordeaux.fr by aliboron.emi.u-bordeaux.fr; Sat, 16 Mar 1996 19:06:35 +0100 Received: by harold.emi.u-bordeaux.fr; Sat, 16 Mar 1996 19:04:12 +0100 Date: Sat, 16 Mar 1996 19:04:12 +0100 Message-Id: <199603161804.TAA13152@harold.emi.u-bordeaux.fr> From: Angel-Ventura Mendo Gomez To: strandh@labri.u-bordeaux.fr Cc: gomez puleggi liegeois@emi.u-bordeaux.fr Subject: exception.h *** EOOH *** Return-Path: Date: Sat, 16 Mar 1996 19:04:12 +0100 From: Angel-Ventura Mendo Gomez To: strandh@labri.u-bordeaux.fr Cc: gomez puleggi liegeois@emi.u-bordeaux.fr Subject: exception.h /* * File: exception.h * Author: Angel-Ventura Mendo Gomez * Purpose: * Error Managing * * $Id: exception.h,v 1.1 1996/03/16 16:16:26 ventura Exp $ */ #ifndef EXCEPCION_H #define EXCEPCION_H #include typedef struct exception *exception; typedef void (*pointer_to_function)(char *,char *,int); extern void exception_pop(void); extern void exception_push(exception); extern int exception_search(exception); extern void *exception_jmp_buf(void); extern void exception_uncaught(char*, char*, int); extern void exception_panic_function_push(exception,void(*)(char *,char *,int) ); extern pointer_to_function exception_search_panic_function(exception); #define DEFINE_EXCEPTION(_EXCEPT_) exception _EXCEPT_=(exception)&_EXCEPT_ #define USE_EXCEPTION(_EXCEPT_) extern exception _EXCEPT_ #define SET_PANIC_FUNCTION(_EXCEPT_,_E_) \ exception_panic_function_push((_EXCEPT_),(_E_)) #define HANDLE(_EXCEPT_,_E1_,_E2_) \ ((exception_push(_EXCEPT_), \ (setjmp(exception_jmp_buf())==0)) \ ? ((_E1_), exception_pop()) \ : (exception_pop(), (_E2_))) #define RAISE(_EXCEPT_) \ (exception_search(_EXCEPT_) \ ? longjmp(exception_jmp_buf(),1) \ : exception_search_panic_function(_EXCEPT_)(#_EXCEPT_,__FILE__,__LINE__) \ ) /* * HANDLE(ALL_EXCEPTIONS,f1,f2) * jumps to f2 when an exception * is received */ #define ALL_EXCEPTIONS others USE_EXCEPTION (others); #endif /* EXCEPCION_H */  1,, Mail-from: From Angel-Ventura.Mendo.Gomez@emi.u-bordeaux.fr Sat Mar 16 19:09:41 1996 Return-Path: Received: from aliboron.emi.u-bordeaux.fr by victor.labri.u-bordeaux.fr (4.1/SM-mailhost-BORDEAUX-1.0) id AA21217; Sat, 16 Mar 96 19:09:40 +0100 Received: from harold.emi.u-bordeaux.fr by aliboron.emi.u-bordeaux.fr; Sat, 16 Mar 1996 19:06:59 +0100 Received: by harold.emi.u-bordeaux.fr; Sat, 16 Mar 1996 19:04:36 +0100 Date: Sat, 16 Mar 1996 19:04:36 +0100 Message-Id: <199603161804.TAA13163@harold.emi.u-bordeaux.fr> From: Angel-Ventura Mendo Gomez To: strandh@labri.u-bordeaux.fr Cc: gomez puleggi liegeois@emi.u-bordeaux.fr Subject: exception.c *** EOOH *** Return-Path: Date: Sat, 16 Mar 1996 19:04:36 +0100 From: Angel-Ventura Mendo Gomez To: strandh@labri.u-bordeaux.fr Cc: gomez puleggi liegeois@emi.u-bordeaux.fr Subject: exception.c /* * File: exception.c * Author: Angel-Ventura Mendo Gomez * Purpose: * Error Managing * * $Id: exception.c,v 1.1 1996/03/16 16:16:18 ventura Exp $ */ #include #include #include #include "exception.h" struct exception { exception header; }; typedef struct context { jmp_buf context_buffer; exception header; struct context *previous; }*context; typedef struct panic_functions_list { pointer_to_function panic_function; exception header; struct panic_functions_list *previous; }*panic_functions_list; static panic_functions_list panic_list=NULL; static context top=NULL; DEFINE_EXCEPTION (others); void exception_panic_function_push(exception e,pointer_to_function panic_function ) { panic_functions_list f=mem_alloc(sizeof(*f)); f->header=e; f->previous=panic_list; f->panic_function=panic_function; panic_list=f; } pointer_to_function exception_search_panic_function(exception e) { panic_functions_list f=panic_list; while (f){ if (f->header==e) return f->panic_function; else f=f->previous; } return exception_uncaught; } void exception_pop(void) { context tmp; assert(top!=NULL); tmp=top; top=top->previous; mem_free(tmp); } void exception_push(exception e) { context c=mem_alloc(sizeof(*c)); c->header=e; c->previous=top; top=c; } int exception_search(exception e) { while(top!=NULL) { if ((top->header==e) || (top->header==others)) return 1; else exception_pop(); } return 0; /* OTHERS: HANDLE(other) */ } /* n'importe quelle esception */ void * exception_jmp_buf(void) { assert(top!=NULL); return top->context_buffer; } void exception_uncaught(char* name, char* file, int line) { fprintf(stderr, "Uncaught exception <%s> raised in \"%s:%d\"\n", name, file, line); exit(1); }  1, answered,, Mail-from: From Stephan.Dupuy@emi.u-bordeaux.fr Fri May 3 02:41:43 1996 Return-Path: Received: from aliboron.emi.u-bordeaux.fr by victor.labri.u-bordeaux.fr (4.1/SM-mailhost-BORDEAUX-1.0) id AA27965; Fri, 3 May 96 02:41:42 +0200 Received: from edwood.emi.u-bordeaux.fr by aliboron.emi.u-bordeaux.fr; Fri, 3 May 1996 02:38:51 +0200 Received: by edwood.emi.u-bordeaux.fr; Fri, 3 May 1996 02:38:48 +0200 Date: Fri, 3 May 1996 02:38:48 +0200 Message-Id: <199605030038.CAA03399@edwood.emi.u-bordeaux.fr> From: Stephan Dupuy To: strandh@labri.u-bordeaux.fr Subject: gqueue *** EOOH *** Return-Path: Date: Fri, 3 May 1996 02:38:48 +0200 From: Stephan Dupuy To: strandh@labri.u-bordeaux.fr Subject: gqueue Bonjour, J'espere ne pas poser une question idiote car il est assez tard :) : j'ai remarque (grace a purify) que dans gqueue.c on a : > gqueue gq_create() > { > gqueue temp = gq_create_aux(); > temp -> cursor_save = gq_create_aux(); > return temp; > } mais que l'on a aussi : > void > gq_destroy(gqueue q) > { > gq_go_beginning(q); > while(!gq_empty(q)) > { > gq_delete(q); > } > mem_free(q->head); > mem_free(q->tail); > mem_free(q); > } et que gq_delete ne libere pas q->cursor_save->head, q->cursor_save->tail et q->cursor_save. Purify signale donc des leaks (44 bytes) apres un simple : % gqueue q = gq_create(); % gq_destroy(q); Pour liberer ces "leaks", il suffit d'ajouter dans gq_destroy : > ... > fin du while % free(q->cursor_save->head); % free(q->cursor_save->tail); % free(q->cursor_save); > ... Qu'en pensez-vous ? (toutes critiques bienvenues) Y-aurait-il une version de la gqueue corrigeant cela ? Merci par avance de vos explications, Stephan Dupuy  1,, Mail-from: From Stephan.Dupuy@emi.u-bordeaux.fr Thu May 30 11:55:28 1996 Return-Path: Received: from aliboron.emi.u-bordeaux.fr by victor.labri.u-bordeaux.fr (4.1/SM-mailhost-BORDEAUX-1.0) id AA04991; Thu, 30 May 96 11:55:27 +0200 Received: from puycibot.emi.u-bordeaux.fr by aliboron.emi.u-bordeaux.fr; Thu, 30 May 1996 11:52:04 +0200 Received: by puycibot.emi.u-bordeaux.fr; Thu, 30 May 1996 11:52:01 +0200 Date: Thu, 30 May 1996 11:52:01 +0200 Message-Id: <199605300952.LAA07185@puycibot.emi.u-bordeaux.fr> From: Stephan Dupuy To: Robert.Strandh@labri.u-bordeaux.fr In-Reply-To: <9605300936.AA04756@victor.labri.u-bordeaux.fr> (message from Robert STRANDH on Thu, 30 May 96 11:36:05 +0200) Subject: Re: gqueue *** EOOH *** Return-Path: Date: Thu, 30 May 1996 11:52:01 +0200 From: Stephan Dupuy To: Robert.Strandh@labri.u-bordeaux.fr In-Reply-To: <9605300936.AA04756@victor.labri.u-bordeaux.fr> (message from Robert STRANDH on Thu, 30 May 96 11:36:05 +0200) Subject: Re: gqueue Ma proposition de correction n'est pas correcte, c'est maintenant : >void >gq_destroy(gqueue q) >{ > gq_go_beginning(q); > while(!gq_empty(q)) > { > gq_delete(q); > } > > /* Dupuy's modification */ > gq_make_empty(q->cursor_save); > mem_free(q->cursor_save->head); > mem_free(q->cursor_save->tail); > mem_free(q->cursor_save); > /* end of Dupuy's */ > > mem_free(q->head); > mem_free(q->tail); > mem_free(q); >} mais par manque de temps (exams) je ne peux verifier ces essais. Je ne suis pas particulierement presse de recuperer une gqueue totalement correcte, mais je me tiendrai au courant car c'est un module assez essentiel que j'utiliserai encore. Merci de votre reponse, Stephan Dupuy