Re: Memory leak suspicion in wap-appl.c

"lijl" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <004001c2b844$6541e760$4006a8c0@LocalHost>
i think there is no memory leak.

1.about set_refer_url()
 sm->referer_url = octstr_duplicate(url);
2. about octstr.h
#define octstr_duplicate(ostr) gw_claim_area(octstr_duplicate_real((ostr)))
3.about octstr.h
Octstr *octstr_duplicate_real(Octstr *ostr)
{
    if (ostr == NULL)
        return NULL;
    seems_valid(ostr);
    return octstr_create_from_data(ostr->data, ostr->len);
}

4.about octstr.h
#define octstr_create_from_data(data, len)\
    gw_claim_area(octstr_create_from_data_real((data), (len)))
5about octstr.h
Octstr *octstr_create_from_data_real(const char *data, long len)
{
    Octstr *ostr;

    gw_assert(len >= 0);
    if (data == NULL)
        gw_assert(len == 0);

    ostr = gw_malloc(sizeof(*ostr));
    if (len == 0) {
        ostr->len = 0;
        ostr->size = 0;
        ostr->data = NULL;
    } else {
        ostr->len = len;
        ostr->size = len + 1;
        ostr->data = gw_malloc(ostr->size);
        memcpy(ostr->data, data, len);
        ostr->data[len] = '\0';
    }
    ostr->immutable = 0;
    seems_valid(ostr);
    return ostr;
}
6about gwmem.h
#define gw_claim_area(ptr) (gw_native_noop(ptr))
7about gwmem_native.c
void *gw_native_noop(void *ptr) { return ptr; }
this is memory allocated to url.


----------------------------------------------------------------
8. in  wap_app.c   function  return_reply()

octstr_destroy(url);          /* same as content.url */
this is memory free.

----- Original Message ----- 
From: "Vjacheslav Chekushin" <[email protected]>
To: "devel" <[email protected]>
Sent: Thursday, January 09, 2003 9:07 PM
Subject: Memory leak suspicion in wap-appl.c


> Hi, list.
> I suspect memory leak in wap-appl.c
> It's about set_referer_url():
> 
> static void set_referer_url(Octstr *url, WSPMachine *sm)
> {
>          gw_assert(url != NULL);
>          gw_assert(sm != NULL);
> 
>      sm->referer_url = octstr_duplicate(url);
> }
> 
> In wap-appl.c we use it:
> 
>              if (session_id != -1) {
>                  debug("wap.wsp.http",0,"WSP: Setting Referer URL to <%s>",
>                        octstr_get_cstr(url));
>                  if ((sm = find_session_machine_by_id(session_id)) != NULL) {
>                      set_referer_url(url, sm);
>                  } else {
>                      error(0,"WSP: Failed to find session machine for ID %ld",
>                            session_id);
>                  }
>              }
> 
> I don't see where preovious sm->referer_url destroyed.
> Must we before
> sm->referer_url = octstr_duplicate(url);
> Insert
> octstr_destroy(sm->referer_url); ?
> 
> Or may be I simply didn't find where it destroyed ;-) .
> 
> -- 
> Vjacheslav Chekushin                                mailto:[email protected]
> Latvian Mobile Phone Company                        http://www.lmt.lv
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.