zoukankan      html  css  js  c++  java
  • 获取指针指向的内存大小方法

    获取指针指向的内存大小方法

    其实很简单,就是一个库函数

    _msize

    该函数返回在堆上分配的内存块大小,以字节为单位。因此将指针传递给这个函数就可以获取指针指向的内存大小了,不过该指针必须是动态分配的指针才行。

    msdn的资料

    size_t _msize( void *memblock );

    Routine Required Header Compatibility
    _msize <malloc.h> Win 95, Win NT

    For additional compatibility information, see Compatibility in the Introduction.

    Libraries

    LIBC.LIB Single thread static library, retail version
    LIBCMT.LIB Multithread static library, retail version
    MSVCRT.LIB Import library for MSVCRT.DLL, retail version

    Return Value

    _msize returns the size (in bytes) as an unsigned integer.

    Parameter

    memblock

    Pointer to memory block

    Remarks

    The _msize function returns the size, in bytes, of the memory block allocated by a call to calloc, malloc, or realloc.

  • 相关阅读:
    牛券
    探险
    雷达安装
    智力大冲浪
    奶牛玩杂技
    BJWC2008 秦腾与教学评估
    JSOI2010 部落划分
    作诗
    ASP.NET MVC4系列验证机制、伙伴类共享源数据信息(数据注解和验证)
    正则表达式
  • 原文地址:https://www.cnblogs.com/absolute8511/p/1649612.html
Copyright © 2011-2022 走看看