Thread: Allocation time.

  1. #1
    Join Date
    Apr 2015

    Allocation time.

    Greetings to you all !
    let's say I have a fixed array size [3] and given that the number of data to save in the array is maximum 3 elements type of integer, meaning the number of data might be 1 or 2 or 3 elements .. if I want to lower my time complexity is it preferable to not declare fixed array like
     int array[3]
    , but just doing allocation by malloc at everytime I get an element?! thanks in advance.
    what I'm thinking about , may the time of allocation on heap by malloc is greater than fixed allocation ?!

    thanks !

  2. #2
    Registered User
    Join Date
    May 2010
    Do you realize that the fixed sized array is a compile time operation and malloc is a runtime operation? Which means that creating an array using a compile time constant size has the most minimal effect on runtime operations.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how convert uint32_t time to human read form of time?
    By barracuda in forum C Programming
    Replies: 19
    Last Post: 03-21-2015, 12:29 AM
  2. Replies: 5
    Last Post: 04-17-2013, 11:32 PM
  3. Replies: 2
    Last Post: 04-17-2013, 12:25 AM
  4. Help! -Linked Lists, Memory Allocation, Time Steps, Debugg
    By MetallicaX in forum C Programming
    Replies: 2
    Last Post: 03-14-2009, 08:50 PM
  5. Memory allocation error (Nicely formatted this time)
    By killiansman in forum C Programming
    Replies: 1
    Last Post: 06-08-2007, 11:14 AM

Tags for this Thread