Revision history for KeyPgReallocate


Revision [21105]

Last edited on 2016-03-13 09:42:33 by fxm [Formatting]

No Differences

Revision [20481]

Edited on 2016-02-10 16:07:34 by DkLwikki [Update link format]
Additions:
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Reallocate** [[KeyPgCdecl|cdecl]] ( [[KeyPgByval|byval]] //pointer// [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]], [[KeyPgByval|byval]] //count// [[KeyPgAs|as]] [[KeyPgUinteger|uinteger]] ) [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]]
Attempts to reallocate, or resize, memory previously allocated with ##[[KeyPgAllocate|Allocate]]## or ##[[KeyPgCallocate|Callocate]]##. The contents of the buffer are preserved, although if ##//count//## is less than the original size of the memory block, the buffer will be truncated. If the size is increased, the added memory range is not initialized to anything.
Reallocated memory must be freed with ##[[KeyPgDeallocate|Deallocate]]## when no longer needed.
If ##//pointer//## is null (##0##), then ##""ReAllocate""## behaves identically to ##[[KeyPgAllocate|Allocate]]##. If ##//pointer//## is valid and ##//count//## is null (0), then ##""ReAllocate""## behaves similar to ##[[KeyPgDeallocate|Deallocate]]## and a null (0) pointer is returned.
If the memory has previously been deallocated by a call to ##[[KeyPgDeallocate|Deallocate]]## or ##""ReAllocate""##, the behavior is undefined.
When manually allocating memory for ##[[KeyPgString|String]]## descriptors (or ##[[KeyPgType|UDT]]##s that contain one), if ##//count//## is larger than the original size of the memory block, the new extra memory range must be explicitly cleared to zeroes before the first string use (for example, using ##[[KeyPgClear|Clear]]##). Otherwise accessing the string will cause undefined results (trying to write or read at a random place in memory, or trying to deallocate a random pointer).
- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Reallocate""**##.
- ##[[KeyPgAllocate|Allocate]]##
- ##[[KeyPgCallocate|Callocate]]##
- ##[[KeyPgDeallocate|Deallocate]]##
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Reallocate** [[KeyPgCdecl cdecl]] ( [[KeyPgByval byval]] //pointer// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]], [[KeyPgByval byval]] //count// [[KeyPgAs as]] [[KeyPgUinteger uinteger]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
Attempts to reallocate, or resize, memory previously allocated with ##[[KeyPgAllocate Allocate]]## or ##[[KeyPgCallocate Callocate]]##. The contents of the buffer are preserved, although if ##//count//## is less than the original size of the memory block, the buffer will be truncated. If the size is increased, the added memory range is not initialized to anything.
Reallocated memory must be freed with ##[[KeyPgDeallocate Deallocate]]## when no longer needed.
If ##//pointer//## is null (##0##), then ##""ReAllocate""## behaves identically to ##[[KeyPgAllocate Allocate]]##. If ##//pointer//## is valid and ##//count//## is null (0), then ##""ReAllocate""## behaves similar to ##[[KeyPgDeallocate Deallocate]]## and a null (0) pointer is returned.
If the memory has previously been deallocated by a call to ##[[KeyPgDeallocate Deallocate]]## or ##""ReAllocate""##, the behavior is undefined.
When manually allocating memory for ##[[KeyPgString String]]## descriptors (or ##[[KeyPgType UDT]]##s that contain one), if ##//count//## is larger than the original size of the memory block, the new extra memory range must be explicitly cleared to zeroes before the first string use (for example, using ##[[KeyPgClear Clear]]##). Otherwise accessing the string will cause undefined results (trying to write or read at a random place in memory, or trying to deallocate a random pointer).
- Not available in the //[[CompilerOptlang -lang qb]]// dialect unless referenced with the alias ##**""__Reallocate""**##.
- ##[[KeyPgAllocate Allocate]]##
- ##[[KeyPgCallocate Callocate]]##
- ##[[KeyPgDeallocate Deallocate]]##


Revision [17535]

Edited on 2015-04-01 12:37:03 by DkLwikki [integer => uinteger]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Reallocate** [[KeyPgCdecl cdecl]] ( [[KeyPgByval byval]] //pointer// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]], [[KeyPgByval byval]] //count// [[KeyPgAs as]] [[KeyPgUinteger uinteger]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Reallocate** [[KeyPgCdecl cdecl]] ( [[KeyPgByval byval]] //pointer// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]], [[KeyPgByval byval]] //count// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]


Revision [17016]

Edited on 2014-03-16 23:39:17 by CountingPine [Minor rephrase]
Additions:
When using ##**Reallocate**##, the ##//result//## pointer must be saved to prevent a potential memory leak, because the original ##//pointer//## may no longer be valid after reallocation. The value of the new pointer should be checked - if it is ##0##, the reallocation has failed - the original ##//pointer//## remains valid, and the amount of memory allocated to it has not changed.
Deletions:
When using ##**Reallocate**##, the ##//result//## pointer must be saved, because the address may have change and the old ##//pointer//## will no longer be valid. The value of the new pointer should be checked - if it is ##0##, the reallocation has failed - the original ##//pointer//## remains valid, and the amount of memory allocated to it has not changed.


Revision [17015]

Edited on 2014-03-16 21:42:33 by CountingPine [Clearer String warning, example comment. misc]
Additions:
Attempts to reallocate, or resize, memory previously allocated with ##[[KeyPgAllocate Allocate]]## or ##[[KeyPgCallocate Callocate]]##. The contents of the buffer are preserved, although if ##//count//## is less than the original size of the memory block, the buffer will be truncated. If the size is increased, the added memory range is not initialized to anything.
When using ##**Reallocate**##, the ##//result//## pointer must be saved, because the address may have change and the old ##//pointer//## will no longer be valid. The value of the new pointer should be checked - if it is ##0##, the reallocation has failed - the original ##//pointer//## remains valid, and the amount of memory allocated to it has not changed.
Reallocated memory must be freed with ##[[KeyPgDeallocate Deallocate]]## when no longer needed.
When manually allocating memory for ##[[KeyPgString String]]## descriptors (or ##[[KeyPgType UDT]]##s that contain one), if ##//count//## is larger than the original size of the memory block, the new extra memory range must be explicitly cleared to zeroes before the first string use (for example, using ##[[KeyPgClear Clear]]##). Otherwise accessing the string will cause undefined results (trying to write or read at a random place in memory, or trying to deallocate a random pointer).
This function is not part of the ""FreeBASIC"" runtime library, it is an alias for the C runtime library's ##//realloc//##, so it's not guaranteed to be thread safe in all platforms.
a = b ' Discard the old pointer and use the new one
Deletions:
Attempts to reallocate, or resize, memory previously allocated with ##[[KeyPgAllocate Allocate]]## or ##[[KeyPgCallocate Callocate]]##. The contents of the buffer are preserved, although if ##//count//## is less than the original size of the memory block, the buffer will be truncated. In case of increase of memory, the added memory range is not initialized.
When use with ##[[KeyPgString String]]## or ##[[KeyPgType UDT]]## containing string, and if ##//count//## is larger than the original size of the memory block, the new extra memory range must be explicitly cleared (set to 0) before the first string use (with for example keyword ##[[KeyPgClear Clear]]##), otherwise a not cleared string descriptor (containing random data) may induce corrupted string or more (trying to write to a random place in memory or trying to deallocate a random pointer).
Reallocated memory must be deallocated, or freed, with ##[[KeyPgDeallocate Deallocate]]## when no longer needed.
This function is not part of the FreeBASIC runtime library, it is an alias for the C runtime library's ##//realloc//##, so it's not guaranteed to be thread safe in all platforms.
a = b


Revision [17009]

Edited on 2014-03-09 14:57:37 by FxMwikki [Added some details]
Additions:
If ##//pointer//## is null (##0##), then ##""ReAllocate""## behaves identically to ##[[KeyPgAllocate Allocate]]##. If ##//pointer//## is valid and ##//count//## is null (0), then ##""ReAllocate""## behaves similar to ##[[KeyPgDeallocate Deallocate]]## and a null (0) pointer is returned.
If the memory has previously been deallocated by a call to ##[[KeyPgDeallocate Deallocate]]## or ##""ReAllocate""##, the behavior is undefined.
Deletions:
If ##//pointer//## is null (##0##), then ##""ReAllocate""## behaves identically to ##[[KeyPgAllocate Allocate]]##.
If ##//pointer//## is valid and ##//count//## is null (0), then ##""ReAllocate""## behaves similar to ##[[KeyPgDeallocate Deallocate]]## and a null (0) pointer is returned.


Revision [15200]

Edited on 2011-08-17 14:12:38 by FxMwikki [Added some details]
Additions:
When use with ##[[KeyPgString String]]## or ##[[KeyPgType UDT]]## containing string, and if ##//count//## is larger than the original size of the memory block, the new extra memory range must be explicitly cleared (set to 0) before the first string use (with for example keyword ##[[KeyPgClear Clear]]##), otherwise a not cleared string descriptor (containing random data) may induce corrupted string or more (trying to write to a random place in memory or trying to deallocate a random pointer).
Deletions:
When use with ##[[KeyPgString String]]## or ##[[KeyPgType UDT]]## containing string, and if ##//count//## is larger than the original size of the memory block, the new extra memory range must be explicitly cleared (set to 0) before the first string use (with for example keyword ##[[KeyPgClear Clear]]##), otherwise a not cleared string descriptor may induce corrupted string or more (crash).


Revision [15197]

Edited on 2011-08-17 13:02:35 by FxMwikki [Added some details]
Additions:
When use with ##[[KeyPgString String]]## or ##[[KeyPgType UDT]]## containing string, and if ##//count//## is larger than the original size of the memory block, the new extra memory range must be explicitly cleared (set to 0) before the first string use (with for example keyword ##[[KeyPgClear Clear]]##), otherwise a not cleared string descriptor may induce corrupted string or more (crash).
Deletions:
When use with ##[[KeyPgString String]]## or ##[[KeyPgType UDT]]## containing string, and if ##//count//## is larger than the original size of the memory block, the new extra memory must be explicitly cleared (set to 0) before the first string use (with for example the keyword ##[[KeyPgClear Clear]]##), otherwise a not cleared string descriptor may induce corrupted string or more (crash).


Revision [15196]

Edited on 2011-08-17 12:54:52 by FxMwikki [Added some details]
Additions:
Attempts to reallocate, or resize, memory previously allocated with ##[[KeyPgAllocate Allocate]]## or ##[[KeyPgCallocate Callocate]]##. The contents of the buffer are preserved, although if ##//count//## is less than the original size of the memory block, the buffer will be truncated. In case of increase of memory, the added memory range is not initialized.
Deletions:
Attempts to reallocate, or resize, memory previously allocated with ##[[KeyPgAllocate Allocate]]## or ##[[KeyPgCallocate Callocate]]##. The contents of the buffer are preserved, although if ##//count//## is less than the original size of the memory block, the buffer will be truncated. In case of increase of memory, the added memory is not initialized.


Revision [15193]

Edited on 2011-08-17 07:33:51 by FxMwikki [Added some details]
Additions:
When use with ##[[KeyPgString String]]## or ##[[KeyPgType UDT]]## containing string, and if ##//count//## is larger than the original size of the memory block, the new extra memory must be explicitly cleared (set to 0) before the first string use (with for example the keyword ##[[KeyPgClear Clear]]##), otherwise a not cleared string descriptor may induce corrupted string or more (crash).
Deletions:
In case of use with ##[[KeyPgString String]]## or ##[[KeyPgType UDT]]## containing string, and if ##//count//## is larger than the original size of the memory block, the new extra memory must be explicitly cleared (set to 0) before the first string use (with for example the keyword ##[[KeyPgClear Clear]]##), otherwise a not cleared string descriptor may induce corrupted string or more (crash).


Revision [15192]

Edited on 2011-08-17 07:30:36 by FxMwikki [Added some details]
Additions:
Attempts to reallocate, or resize, memory previously allocated with ##[[KeyPgAllocate Allocate]]## or ##[[KeyPgCallocate Callocate]]##. The contents of the buffer are preserved, although if ##//count//## is less than the original size of the memory block, the buffer will be truncated. In case of increase of memory, the added memory is not initialized.
Deletions:
Attempts to reallocate, or resize, memory previously allocated with ##[[KeyPgAllocate Allocate]]## or ##[[KeyPgCallocate Callocate]]##. The contents of the buffer are preserved, although if ##//count//## is less than the original size of the memory block, the buffer will be truncated.


Revision [15190]

Edited on 2011-08-17 06:58:14 by FxMwikki [Added some details]
Additions:
In case of use with ##[[KeyPgString String]]## or ##[[KeyPgType UDT]]## containing string, and if ##//count//## is larger than the original size of the memory block, the new extra memory must be explicitly cleared (set to 0) before the first string use (with for example the keyword ##[[KeyPgClear Clear]]##), otherwise a not cleared string descriptor may induce corrupted string or more (crash).
Deletions:
In case of use with ##[[KeyPgString String]]## or ##[[KeyPgType UDT]]## containing string, and if ##//count//## is larger than the original size of the memory block, the new extra memory must be explicitly cleared (set to 0) before the first string use (with for example the keyword ##[[KeyPgClear Clear]]##), otherwise not cleared string descriptor may induce corrupted string or more (crash).


Revision [15189]

Edited on 2011-08-17 06:55:51 by FxMwikki [Added some details]
Additions:
In case of use with ##[[KeyPgString String]]## or ##[[KeyPgType UDT]]## containing string, and if ##//count//## is larger than the original size of the memory block, the new extra memory must be explicitly cleared (set to 0) before the first string use (with for example the keyword ##[[KeyPgClear Clear]]##), otherwise not cleared string descriptor may induce corrupted string or more (crash).
Deletions:
In case of use with ##[[KeyPgString String]]## or ##[[KeyPgType UDT]]## containing string, and if ##//count//## is larger than the original size of the memory block, the new extra memory must be explicitly cleared (set to 0) before the first string use (with for example the keyword ##[[KeyPgClear Clear]]##), otherwise not cleared string descriptor may induce corrupted string or more (crash)


Revision [15188]

Edited on 2011-08-17 06:55:03 by FxMwikki [Added some details]
Additions:
In case of use with ##[[KeyPgString String]]## or ##[[KeyPgType UDT]]## containing string, and if ##//count//## is larger than the original size of the memory block, the new extra memory must be explicitly cleared (set to 0) before the first string use (with for example the keyword ##[[KeyPgClear Clear]]##), otherwise not cleared string descriptor may induce corrupted string or more (crash)
Deletions:
In case of use with ##[[KeyPgString String]]## or ##[[KeyPgType UDT]]## containing string, and if ##//count//## is larger than the original size of the memory block, the new extra memory must be explicitly cleared (set to 0) before the first string use (with for example the keyword ##[[KeyPgClear Clear]]##).


Revision [15187]

Edited on 2011-08-17 06:23:33 by FxMwikki [Added some details]
Additions:
Attempts to reallocate, or resize, memory previously allocated with ##[[KeyPgAllocate Allocate]]## or ##[[KeyPgCallocate Callocate]]##. The contents of the buffer are preserved, although if ##//count//## is less than the original size of the memory block, the buffer will be truncated.
In case of use with ##[[KeyPgString String]]## or ##[[KeyPgType UDT]]## containing string, and if ##//count//## is larger than the original size of the memory block, the new extra memory must be explicitly cleared (set to 0) before the first string use (with for example the keyword ##[[KeyPgClear Clear]]##).
If ##//pointer//## is valid and ##//count//## is null (0), then ##""ReAllocate""## behaves similar to ##[[KeyPgDeallocate Deallocate]]## and a null (0) pointer is returned.
Deletions:
Attempts to reallocate, or resize, memory previously allocated with ##[[KeyPgAllocate Allocate]]##. The contents of the buffer are preserved, although if ##//count//## is less than the original size of the memory block, the buffer will be truncated.


Revision [14593]

Edited on 2010-06-06 04:37:41 by DkLwikki [Missing cdecl]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Reallocate** [[KeyPgCdecl cdecl]] ( [[KeyPgByval byval]] //pointer// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]], [[KeyPgByval byval]] //count// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Reallocate** ( [[KeyPgByval byval]] //pointer// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]], [[KeyPgByval byval]] //count// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]


Revision [14433]

Edited on 2009-08-29 21:56:43 by CountingPine [Remove CamelCase links in "New to FreeBASIC"]
Additions:
- New to ""FreeBASIC""
Deletions:
- New to FreeBASIC


Revision [14007]

Edited on 2008-12-02 09:51:40 by LaananFisher [Updated: minor formatting]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Reallocate** ( [[KeyPgByval byval]] //pointer// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]], [[KeyPgByval byval]] //count// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Reallocate**( [[KeyPgByval byval]] //pointer// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]], [[KeyPgByval byval]] //count// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]


Revision [13451]

The oldest known version of this page was created on 2008-06-24 20:30:59 by CountingPine [Updated: minor formatting]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode