🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #4935

Re: time_t to TDateTime

#4935
From: Bob Gonder
Date: Wed, 12 Oct 2005 15:22
19 lines
1563 bytes
Steve Aletto wrote:

>    struct tm *stm = localtime(&t);
>    if (stm)
>    {..... }
>    return(rv);

>I think this is not thread-safe. Furthermore, it introduces a 
>memory leak due to localtime(), but I don't know whether it can 
>be solved.

Not a leak...
"localtime returns a pointer to the structure containing the time
elements. This structure is a static that is overwritten with each
call."
One might assume that the multithread version of the libs store the
struct in thread local storage.

But you might want to give rv a default value if localtime fails.
Technical Details
Message-ID: <r4aqk11oi1r48eu3qd9knkq2mf7lv31eua@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <434cfde3$1@newsgroups.borland.com> <434d20f1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,abdfe71df549986f
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: time_t to TDateTime
Date: Wed, 12 Oct 2005 08:22:54 -0700
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <r4aqk11oi1r48eu3qd9knkq2mf7lv31eua@4ax.com>
References: <434cfde3$1@newsgroups.borland.com> <434d20f1@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 69.69.88.88
X-Trace: newsgroups.borland.com 1129130424 69.69.88.88 (12 Oct 2005 08:20:24 -0700)
Lines: 21
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail