zoukankan      html  css  js  c++  java
  • calloc malloc realloc

    calloc

    void * calloc ( size_t num, size_t size );

    Allocate space for array in memory
    Allocates a block of memory for an array of num elements, each of them size bytes long, and initializes all its bits to zero.

    The effective result is the allocation of an zero-initialized memory block of (num * size) bytes.

    -------------------

    malloc

    void * malloc ( size_t size );

    Allocate memory block
    Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.

    The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.


    ------------------

    realloc

    void * realloc ( void * ptr, size_t size );

    Reallocate memory block
    The size of the memory block pointed to by the ptr parameter is changed to the size bytes, expanding or reducing the amount of memory available in the block.

    The function may move the memory block to a new location, in which case the new location is returned. The content of the memory block is preserved up to the lesser of the new and old sizes, even if the block is moved. If the new size is larger, the value of the newly allocated portion is indeterminate.

    In case that ptr is NULL, the function behaves exactly as malloc, assigning a new block of size bytes and returning a pointer to the beginning of it.

    In case that the size is 0, the memory previously allocated in ptr is deallocated as if a call to free was made, and a NULL pointer is returned.


    Parameters

    ptr
        Pointer to a memory block previously allocated with malloc, calloc or realloc to be reallocated.
        If this is NULL, a new block is allocated and a pointer to it is returned by the function.
    size
        New size for the memory block, in bytes.
        If it is 0 and ptr points to an existing block of memory, the memory block pointed by ptr is deallocated and a NULL pointer is returned.

  • 相关阅读:
    基于jQuery和Bootstrap的手风琴垂直菜单
    JavaScript右下角信息提示插件Notyf
    强大的jQuery幻灯片播放插件 支持全拼、拖拽和下载等功能
    较常用的Math方法及ES6中的扩展
    ES6 完全使用手册
    如何用纯 CSS 创作一个小球上台阶的动画
    BZOJ_1503_[NOI2004]郁闷的出纳员_权值线段树
    BZOJ_2815_[ZJOI2012]灾难 倍增lca + 构造
    BZOJ_3316_JC loves Mkk_ 二分答案 + 单调队列
    BZOJ_1260_[CQOI2007]涂色paint _区间DP
  • 原文地址:https://www.cnblogs.com/greencolor/p/2421231.html
Copyright © 2011-2022 走看看