• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CoreFoundation and CFDate functions - question on memory de-allocation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CoreFoundation and CFDate functions - question on memory de-allocation


  • Subject: CoreFoundation and CFDate functions - question on memory de-allocation
  • From: Kent Behrends <email@hidden>
  • Date: Wed, 7 Jan 2004 22:47:48 -0800

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi:

I have a question on the code fragment below. It does what I want, namely returning the current time in yyyy-mm-dd hh:mm:ss format, but it seems to have allocated memory to hold the converted date time string.

Do I need to release this memory?

The code is expected to run every 5 seconds or so in the background for as long as the systems is up.


// Get current CFDate
CFDateRef aCFDate = CFDateCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent());

// Create a date formatter and set its format string
CFDateFormatterRef dateFormatter1 = CFDateFormatterCreate(NULL, NULL, kCFDateFormatterShortStyle, kCFDateFormatterShortStyle);
CFDateFormatterSetFormat(dateFormatter1, CFSTR("yyyy-MM-dd HH:mm:ss"));
CFStringRef dateStr = CFDateFormatterCreateStringWithDate(NULL, dateFormatter1, aCFDate);

// Copy formatted string into loopData struct
strncpy(loopData->dateTime,CFStringGetCStringPtr(dateStr, CFStringGetSystemEncoding()),19); // yyyy-mm-dd hh:mm:ss'\0'

- ---
Kent Behrends
BEHR Consulting International
+1.909.393.5265 Office
+1.909.642.2747 Cell
+1.630.214.6898 FAX
http://www.bci.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)

iD8DBQE//P0Z9jwFQb3SI4gRAgNaAJ9axgy8wUU6K6MB6Wk+AUf98/j8jACfehto
AMOk2NmqBrCs2LJSewfLdpU=
=jAQM
-----END PGP SIGNATURE-----
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: CoreFoundation and CFDate functions - question on memory de-allocation
      • From: j o a r <email@hidden>
  • Prev by Date: Re: how to be informed that a movie is done playing?
  • Next by Date: Re: CoreFoundation and CFDate functions - question on memory de-allocation
  • Previous by thread: Re: Online Cocoa Developer Documentation Updated
  • Next by thread: Re: CoreFoundation and CFDate functions - question on memory de-allocation
  • Index(es):
    • Date
    • Thread