mirror of
https://github.com/ksherlock/mpw.git
synced 2024-12-21 09:29:34 +00:00
mplite_resize (in-place realloc)
This commit is contained in:
parent
3c65212ba3
commit
dd7a6d9862
@ -168,6 +168,27 @@ MPLITE_API void *mplite_realloc(mplite_t *handle, const void *pPrior,
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// like realloc but will not resize.
|
||||||
|
// for compatibility with MM::SetPtrSize
|
||||||
|
MPLITE_API int mplite_resize(mplite_t *handle, const void *pPrior,
|
||||||
|
const int nBytes)
|
||||||
|
{
|
||||||
|
int nOld;
|
||||||
|
|
||||||
|
/* Check the parameters */
|
||||||
|
if ((NULL == handle) || (NULL == pPrior) || (nBytes <= 0) ||
|
||||||
|
(nBytes & (nBytes - 1))) {
|
||||||
|
return MPLITE_ERR_INVPAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
nOld = mplite_size(handle, pPrior);
|
||||||
|
if (nBytes <= nOld) {
|
||||||
|
return MPLITE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MPLITE_ERR_INVPAR; // not really, but ok.
|
||||||
|
}
|
||||||
|
|
||||||
MPLITE_API int mplite_roundup(mplite_t *handle, const int n)
|
MPLITE_API int mplite_roundup(mplite_t *handle, const int n)
|
||||||
{
|
{
|
||||||
int iFullSz;
|
int iFullSz;
|
||||||
|
@ -192,6 +192,11 @@ MPLITE_API void mplite_free(mplite_t *handle, const void *pPrior);
|
|||||||
MPLITE_API void *mplite_realloc(mplite_t *handle, const void *pPrior,
|
MPLITE_API void *mplite_realloc(mplite_t *handle, const void *pPrior,
|
||||||
const int nBytes);
|
const int nBytes);
|
||||||
|
|
||||||
|
|
||||||
|
MPLITE_API int mplite_resize(mplite_t *handle, const void *pPrior,
|
||||||
|
const int nBytes);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Round up a request size to the next valid allocation size.
|
* @brief Round up a request size to the next valid allocation size.
|
||||||
* @param[in,out] handle Pointer to an initialized @ref mplite_t object
|
* @param[in,out] handle Pointer to an initialized @ref mplite_t object
|
||||||
|
Loading…
Reference in New Issue
Block a user