<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: C question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/c-question/m-p/3448488#M852243</link>
    <description>Man free returns the first "hit" it finds unless you specify a section. Man 3 free should display the function for you. Now for the bad news, free works just the same on both platforms. I suspect that you are trying to free a chunk of memory that was not allocated by malloc, calloc, et al or you are trying to free the same chunk of memory more than once.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 21 Dec 2004 18:18:02 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2004-12-21T18:18:02Z</dc:date>
    <item>
      <title>C question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-question/m-p/3448487#M852242</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I have moved my C program from HP-UX 11.11 to Linux AS release 3 environment. I can recompiled the code on Linux successfully but I got memory dump error when try to run the executable. The problem is caused by free() function I used deallocate memory in the code. This is my gcc compiler version.&lt;BR /&gt;&lt;BR /&gt;"Reading specs from /usr/lib/gcc-lib/i386-redhat-linux7/2.96/specs&lt;BR /&gt;gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-123)"&lt;BR /&gt;&lt;BR /&gt;When I check the manpage for "free" on Linux return a different function (free - display information about free and used memory on the system).&lt;BR /&gt;&lt;BR /&gt;How do I deallocate memory on Linux platfrom?&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Tue, 21 Dec 2004 17:56:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-question/m-p/3448487#M852242</guid>
      <dc:creator>Ridzuan Zakaria</dc:creator>
      <dc:date>2004-12-21T17:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: C question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-question/m-p/3448488#M852243</link>
      <description>Man free returns the first "hit" it finds unless you specify a section. Man 3 free should display the function for you. Now for the bad news, free works just the same on both platforms. I suspect that you are trying to free a chunk of memory that was not allocated by malloc, calloc, et al or you are trying to free the same chunk of memory more than once.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Dec 2004 18:18:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-question/m-p/3448488#M852243</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-12-21T18:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: C question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-question/m-p/3448489#M852244</link>
      <description>Hi Clay,&lt;BR /&gt;&lt;BR /&gt;I am using getpwuid function and assuming it uses malloc(). Maybe I am wrong. The code with free() work just fine on HP-UX.&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Tue, 21 Dec 2004 18:22:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-question/m-p/3448489#M852244</guid>
      <dc:creator>Ridzuan Zakaria</dc:creator>
      <dc:date>2004-12-21T18:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: C question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-question/m-p/3448490#M852245</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;This is my code.&lt;BR /&gt;&lt;BR /&gt;    sessionid = (struct passwd*)getpwuid(getuid());&lt;BR /&gt;    if (sessionid != NULL)&lt;BR /&gt;    {&lt;BR /&gt;    strcpy(user,sessionid-&amp;gt;pw_name);&lt;BR /&gt;    free(sessionid);&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Tue, 21 Dec 2004 18:25:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-question/m-p/3448490#M852245</guid>
      <dc:creator>Ridzuan Zakaria</dc:creator>
      <dc:date>2004-12-21T18:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: C question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-question/m-p/3448491#M852246</link>
      <description>Ah, there's your problem (and it's working by accident on HP-UX). getpwuid returns either a NULL (on failure) or a pointer to a static address so that repeated invocations of getpwuid return the same address. The value returned shound NEVER be freed because it was never malloc'ed.&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Dec 2004 18:28:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-question/m-p/3448491#M852246</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-12-21T18:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: C question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-question/m-p/3448492#M852247</link>
      <description>Thanks Clay.</description>
      <pubDate>Tue, 21 Dec 2004 18:33:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-question/m-p/3448492#M852247</guid>
      <dc:creator>Ridzuan Zakaria</dc:creator>
      <dc:date>2004-12-21T18:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: C question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-question/m-p/3448493#M852248</link>
      <description>Better yet, where possible, use the re-entrant versions of those functions. They do the same, but are much safer:&lt;BR /&gt;&lt;BR /&gt;--8&amp;lt;---&lt;BR /&gt;       The  getpwnam_r () and getpwuid_r () functions find the same&lt;BR /&gt;       information, but store the retrieved passwd  structure  in&lt;BR /&gt;       the space pointed to by pwbuf.  This passwd structure con-&lt;BR /&gt;       tains pointers to strings, and these strings are stored in&lt;BR /&gt;       the  buffer  buf  of size buflen.  A pointer to the result&lt;BR /&gt;       (in case of success) or NULL (in case no entry  was  found&lt;BR /&gt;       or an error occurred) is stored in *pwbufp.&lt;BR /&gt;--&amp;gt;8---&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Wed, 22 Dec 2004 02:29:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-question/m-p/3448493#M852248</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-12-22T02:29:50Z</dc:date>
    </item>
  </channel>
</rss>

