aboutsummaryrefslogtreecommitdiffstats
path: root/include/gos
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2013-07-20 21:57:01 +1000
committerinmarket <andrewh@inmarket.com.au>2013-07-20 21:57:01 +1000
commit2bef5da2f3a3a5c3f1e667d5f50c2f28f6d96baf (patch)
tree781f37ef9fc7ded9180ced186bb205ffe1fd13d2 /include/gos
parentb91097e3116b6edd21f00478b115cb611fff34b1 (diff)
downloaduGFX-2bef5da2f3a3a5c3f1e667d5f50c2f28f6d96baf.tar.gz
uGFX-2bef5da2f3a3a5c3f1e667d5f50c2f28f6d96baf.tar.bz2
uGFX-2bef5da2f3a3a5c3f1e667d5f50c2f28f6d96baf.zip
Added gfxRealloc()
Diffstat (limited to 'include/gos')
-rw-r--r--include/gos/chibios.h1
-rw-r--r--include/gos/gos.h20
-rw-r--r--include/gos/win32.h1
3 files changed, 22 insertions, 0 deletions
diff --git a/include/gos/chibios.h b/include/gos/chibios.h
index 5193d506..cfbc049e 100644
--- a/include/gos/chibios.h
+++ b/include/gos/chibios.h
@@ -76,6 +76,7 @@ extern "C" {
#define gfxMutexDestroy(pmutex) {}
#define gfxMutexEnter(pmutex) chMtxLock(pmutex)
#define gfxMutexExit(pmutex) chMtxUnlock()
+void *gfxRealloc(void *ptr, size_t oldsz, size_t newsz);
void gfxSleepMilliseconds(delaytime_t ms);
void gfxSleepMicroseconds(delaytime_t ms);
void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);
diff --git a/include/gos/gos.h b/include/gos/gos.h
index fe45ce60..84a2fd0a 100644
--- a/include/gos/gos.h
+++ b/include/gos/gos.h
@@ -128,6 +128,26 @@
void *gfxAlloc(size_t sz);
/**
+ * @brief Re-allocate memory
+ * @return A pointer to the new memory area or NULL if there is no more memory available
+ *
+ * @param[in] ptr The old memory area to be increased/decreased in size
+ * @param[in] oldsz The size in bytes of the old memory area
+ * @param[in] newsz The size in bytes of the new memory area
+ *
+ * @note Some operating systems don't use the oldsz parameter as they implicitly know the size of
+ * old memory area. The parameter must always be supplied however for API compatibility.
+ * @note gfxRealloc() can make the area smaller or larger but may have to return a different pointer.
+ * If this occurs the new area contains a copy of the data from the old area. The old memory
+ * pointer should not be used after this routine as the original area may have been freed.
+ * @note If there is insufficient memory to create the new memory region, NULL is returned and the
+ * old memory area is left unchanged.
+ *
+ * @api
+ */
+ void *gfxRealloc(void *ptr, size_t oldsz, size_t newsz);
+
+ /**
* @brief Free memory
*
* @param[in] ptr The memory to free
diff --git a/include/gos/win32.h b/include/gos/win32.h
index fbb45d9b..a8dd6d6f 100644
--- a/include/gos/win32.h
+++ b/include/gos/win32.h
@@ -55,6 +55,7 @@ typedef HANDLE gfxThreadHandle;
#define gfxExit() ExitProcess(0)
#define gfxAlloc(sz) malloc(sz)
+#define gfxRealloc(p,osz,nsz) realloc(p, nsz)
#define gfxFree(ptr) free(ptr)
#define gfxSleepMilliseconds(ms) Sleep(ms)
#define gfxYield() Sleep(0)