pike.git / src / modules / _Roxen / roxen.c

version» Context lines:

pike.git/src/modules/_Roxen/roxen.c:41:      #define THP ((struct header_buf *)Pike_fp->current_storage)   struct header_buf   {    char *headers;    char *pnt;    ptrdiff_t hsize, left;    int slash_n, spc;   };    + static void f_hp_init( struct object *o ) + { +  THP->headers = NULL; +  THP->pnt = NULL; +  THP->hsize = 0; + } +    static void f_hp_exit( struct object *o )   {    if( THP->headers )    free( THP->headers ); -  +  THP->headers = NULL; +  THP->pnt = NULL; +  THP->hsize = 0;   }      static void f_hp_feed( INT32 args )   /*! @decl array(string|mapping) feed(string data)    */   {    struct pike_string *str = Pike_sp[-1].u.string;    struct header_buf *hp = THP;    int tot_slash_n=hp->slash_n, slash_n = 0, spc = hp->spc;    char *pp,*ep;
pike.git/src/modules/_Roxen/roxen.c:203:    }    }    push_mapping( headers );    f_aggregate( 3 ); /* data, firstline, headers */   }      static void f_hp_create( INT32 args )   /*! @decl void create(void)    */   { -  THP->headers = malloc( 8192 ); +  if (THP->headers) { +  free(THP->headers); +  THP->headers = NULL; +  } +  THP->headers = xalloc( 8192 );    THP->pnt = THP->headers;    THP->hsize = 8192;    THP->left = 8192;    THP->spc = THP->slash_n = 0;    pop_n_elems(args);    push_int(0);   }      /*! @endclass    */
pike.git/src/modules/_Roxen/roxen.c:469:    "function(mapping(string:string|array(string)):string)", 0 );       pike_add_function("http_decode_string", f_http_decode_string,    "function(string:string)", 0 );       pike_add_function("html_encode_string", f_html_encode_string,    "function(mixed:string)", 0 );       start_new_program();    ADD_STORAGE( struct header_buf ); +  set_init_callback( f_hp_init );    set_exit_callback( f_hp_exit );    pike_add_function( "feed", f_hp_feed, "function(string:array(string|mapping))",0 );    pike_add_function( "create", f_hp_create, "function(:void)", ID_STATIC );    end_class( "HeaderParser", 0 );   }      void pike_module_exit()   {   }