# HG changeset patch # User Mario de Sousa # Date 1347552760 -3600 # Node ID a77514dd00409fbe5c364744ee1049a45f6fe3b8 # Parent 7421cb63defa33cf5e14a11e58088dedffec0856 Adjust coding style. diff -r 7421cb63defa -r a77514dd0040 absyntax/absyntax.cc --- a/absyntax/absyntax.cc Sat Sep 08 10:44:04 2012 +0100 +++ b/absyntax/absyntax.cc Thu Sep 13 17:12:40 2012 +0100 @@ -82,21 +82,33 @@ list_c::list_c( int fl, int fc, const char *ffile, long int forder, int ll, int lc, const char *lfile, long int lorder) - :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder),c(LIST_CAP_INIT),n(0),elements((symbol_c**)malloc(LIST_CAP_INIT*sizeof(symbol_c*))) {} + :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder),c(LIST_CAP_INIT) { + n = 0; + elements = (symbol_c**)malloc(LIST_CAP_INIT*sizeof(symbol_c*)); + if (NULL == elements) ERROR_MSG("out of memory"); +} + list_c::list_c(symbol_c *elem, int fl, int fc, const char *ffile, long int forder, int ll, int lc, const char *lfile, long int lorder) - :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder),c(LIST_CAP_INIT),n(0),elements((symbol_c**)malloc(LIST_CAP_INIT*sizeof(symbol_c*))) - { add_element(elem); } + :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder),c(LIST_CAP_INIT) { + n = 0; + elements = (symbol_c**)malloc(LIST_CAP_INIT*sizeof(symbol_c*)); + if (NULL == elements) ERROR_MSG("out of memory"); + add_element(elem); +} + /* append a new element to the end of the list */ void list_c::add_element(symbol_c *elem) { // printf("list_c::add_element()\n"); - if((c <= n) && !(elements=(symbol_c**)realloc(elements,(c+=LIST_CAP_INCR)*sizeof(symbol_c *)))) ERROR_MSG("out of memory"); + if (c <= n) + if (!(elements=(symbol_c**)realloc(elements,(c+=LIST_CAP_INCR)*sizeof(symbol_c *)))) + ERROR_MSG("out of memory"); elements[n++] = elem; - if(elem == NULL) return; + if (NULL == elem) return; /* adjust the location parameters, taking into account the new element. */ if ((first_line == elem->first_line) && diff -r 7421cb63defa -r a77514dd0040 absyntax/absyntax.hh --- a/absyntax/absyntax.hh Sat Sep 08 10:44:04 2012 +0100 +++ b/absyntax/absyntax.hh Thu Sep 13 17:12:40 2012 +0100 @@ -166,7 +166,7 @@ /* a list of symbols... */ class list_c: public symbol_c { public: - int c,n; + int c,n; /* c: current capacity of list (malloc'd memory); n: current number of elements in list */ symbol_c **elements; public: