Find the answer to your Linux question:
Results 1 to 4 of 4
Dear All, Where can i find definition of ctime_r system call and malloc function. i searched in man pages but no luck.(i know that for compilation is uses lib file ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2013
    Posts
    2

    Where can i find definition of ctime_r system call and malloc function


    Dear All,

    Where can i find definition of ctime_r system call and malloc function.

    i searched in man pages but no luck.(i know that for compilation is uses lib file but i require definition)

    Thanks and regards,
    ganesh

  2. #2
    oz
    oz is offline
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,733
    Hello and welcome aboard!

    The definitions for each should come up with a quick google search using search terms like:

    ctime_r

    ctime_r system call

    malloc

    malloc function
    oz

  3. #3
    Just Joined!
    Join Date
    Mar 2013
    Posts
    2
    Thanks for the reply,

    i have found the malloc definition but,unable to find the ctime_r.

    when i searched for ctime_r,it gives me the usage,and some examples .

    the reason i am asking for definition,whether in that function is there any memory allocation done.

    Thanks and regards,
    ganesh

  4. #4
    Just Joined! mrbruno's Avatar
    Join Date
    Jan 2013
    Location
    /MilkyWay/Sol/Earth/USA/NC/Raleigh
    Posts
    63
    Quote Originally Posted by ganesh_9 View Post
    Thanks for the reply,

    i have found the malloc definition but,unable to find the ctime_r.

    when i searched for ctime_r,it gives me the usage,and some examples .

    the reason i am asking for definition,whether in that function is there any memory allocation done.

    Thanks and regards,
    ganesh
    The page from the Single Unix Specification may help.

    The short answer is no, ctime_r() will not allocate memory. In general, APIs ending in _r are "thread-safe" and have traditional counterparts (ctime() in the case of ctime_r()) which are not thread-safe and it's very common for them to be documented on the same page since they have nearly identical behavior. ctime() is not thread-safe because it uses a single static area of memory in each process to return its result. If you have two or more threads running, you run the risk of one of them stomping on the result before another thread receives it. ctime_r() gets around that problem by requiring the calling thread to provide the storage.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •