--- parser3/src/classes/date.C 2003/01/28 15:42:39 1.42.2.2 +++ parser3/src/classes/date.C 2003/03/17 14:48:04 1.42.4.1 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_DATE_C="$Date: 2003/01/28 15:42:39 $"; +static const char* IDENT_DATE_C="$Date: 2003/03/17 14:48:04 $"; #include "classes.h" #include "pa_request.h" @@ -17,7 +17,7 @@ static const char* IDENT_DATE_C="$Date: class MDate : public Methoded { public: // VStateless_class - ValuePtr create_new_value() { return ValuePtr(new VDate(0)); } + Value *create_new_value(Pool& pool) { return new(pool) VDate(pool, 0); } public: MDate(Pool& pool); @@ -25,24 +25,6 @@ public: // Methoded bool used_directly() { return true; } }; -// helpers - -Table date_calendar_table_template; -/* - // date_calendar_table_template - { - Array *columns=NEW Array(pool); - for(int i=0; i<=6; i++) { - char *column=(char *)pool.malloc(MAX_NUMBER); - snprintf(column, MAX_NUMBER, "%d", i); - *columns+=NEW String(pool, column); // .i column name - } - *columns+=NEW String(pool, DATE_CALENDAR_WEEKNO_NAME); - *columns+=NEW String(pool, DATE_CALENDAR_WEEKYEAR_NAME); - date_calendar_table_template=NEW Table(pool, 0, columns); - } -*/ - // methods static void _now(Request& r, const String& method_name, MethodParams *params) { @@ -152,7 +134,7 @@ static void _sql_string(Request& r, cons Pool& pool=r.pool(); VDate *vdate=static_cast(r.get_self()); int size=1+ 4+1+2+1+2 +1+ 2+1+2+1+2 +1 +1; - char *buf=(char *)pool.malloc(size); + char *buf=(char *)pool.malloc_atomic(size); time_t time=vdate->get_time(); size=strftime(buf, size, "%Y-%m-%d %H:%M:%S", localtime(&time)); @@ -262,7 +244,7 @@ static Table *fill_month_days(Request& r for(int wday=0; wday<7; wday++, _day++) { String *cell=new(pool) String(pool); if(_day>=1 && _day<=monthDays) { - char *buf=(char *)pool.malloc(2+1); + char *buf=(char *)pool.malloc_atomic(2+1); cell->APPEND_CLEAN(buf, sprintf(buf, "%02d", _day), method_name.origin().file, method_name.origin().line); } @@ -279,7 +261,7 @@ static Table *fill_month_days(Request& r // http://www.merlyn.demon.co.uk/weekinfo.htm const int FirstThurs[] = {7,5,4,3,2,7,6,5,4,2,1,7,6,4,3,2,1,6,5,4,3,1,7,6,5,3,2,1}; int n=1 + (tms.tm_yday-(FirstThurs[weekyear % 28]-3))/7; - weekno_buf=(char *)pool.malloc(weekno_buf_size); + weekno_buf=(char *)pool.malloc_atomic(weekno_buf_size); weekno_size=snprintf(weekno_buf, weekno_buf_size, "%02d", n); } @@ -294,7 +276,7 @@ static Table *fill_month_days(Request& r // appending year week year { String *cell=new(pool) String(pool); - char *buf=(char *)pool.malloc(4+1); + char *buf=(char *)pool.malloc_atomic(4+1); cell->APPEND_CLEAN(buf, sprintf(buf, "%02d", weekyear), method_name.origin().file, method_name.origin().line); row+=cell; @@ -337,7 +319,7 @@ static Table *fill_week_days(Request& r, tm *tmOut=localtime(&t); Array& row=*new(pool) Array(pool, 4); #define WDFILL(size, value) { \ - char *buf=(char *)pool.malloc(size+1); \ + char *buf=(char *)pool.malloc_atomic(size+1); \ String *cell=new(pool) String(pool); \ cell->APPEND_CLEAN(buf, sprintf(buf, "%0"#size"d", value), \ method_name.origin().file, \