Ethereal-dev: Re: [Ethereal-dev] Memory allocation audit, janitor project, EMEMification of di

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <gharris@xxxxxxxxx>
Date: Wed, 17 Aug 2005 00:01:31 -0700
Tomas Kukosa wrote:

I would have one question. Is it really necessary to use g_strdp() in following code (from packet-camel.c)?

  if (pinfo->private_data != NULL){
    version_ptr = strrchr(pinfo->private_data,'.');
    if (version_ptr) {
      version_str = g_strdup(version_ptr+1);
      application_context_version = atoi(version_str);
      g_free(version_str);
    }
  }

As far as I know, the "g_strdup()" is completely redundant or is insufficient. If the string supplied in "pinfo->private_data" isn't null-terminated, then "g_strdup()" isn't enough (and the "strrchr()" isn't guaranteed to work); if it is null-terminated, it's not necessary.