Re: amount of memory allocated to a pointer



pratap wrote about getting the size of an allocated memory block:

one more way is using _msize(p)
this is even more easier than remembering! !-)


1) This is neither standard nor portable.
2) On implementations where this is available, it works with malloc'ed blocks ONLY.
3) Even on these implementations, it DOESN'T work. It tends to give sizes larger than the allocated size; Giving the effective size of allocation (counting alignments), and not the requested size.
4) It transforms C in BASIC.
With typical C functions accepting a pointer memory block as parameter as well as some size information, you can pass memory you've allocated from anywhere, you can write your own memory pool or sub-heap of malloc's heap, you can manually cut your memory blocks in pieces. Programmers are very used to have the freedom of memory use.
Using _msize is removing this freedom.

Lazyiness has many disadvantages.

--
You can contact me at <tabkanDELETETHISnaz@xxxxxxxxxxxxxxxxxx>
.



Relevant Pages

  • Re: "new byte[132]" alignment on 16 bytes
    ... Byte arrays are allocated on the managed heap and this ... And pass this Buffer to a unmanaged C++ function that executes Assembler SSE ... The SSE instructon set assumes that the starting physical memory block is ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: malloc vs. realloc
    ... on your particular compiler and operating system, ... Perhaps a better memory allocation ... If you really need to shrink the memory block, ...
    (comp.lang.c)
  • Re: Avoiding copying an array in JNI
    ... The memory block keeps track of where it is in the processing - and so it essentially runs in to background until done. ... The calling program keeps calling the dll until the dll says it is 100% done. ... But this copy - with accompanying allocation of a new block of memory - makes the processing impossible. ... preserving the computation's state when the GUI needs the ...
    (comp.lang.java.help)
  • Re: how many function copy will be created for normal member function and static member function ??
    ... Jigar Mehta wrote: ... what if we make 10 objects of that class, will 10 different allocation of memory block be made for each object for that member function ?? ...
    (microsoft.public.vc.language)