summaryrefslogtreecommitdiff
path: root/nuttx/graphics
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-03-09 21:12:20 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-03-09 21:12:20 +0000
commitdda5be5c1fc672b5d9cb3a910b5e0cb0a41046c5 (patch)
tree0af32db840a032a50312791977b7d129def1d5b3 /nuttx/graphics
parent2ac33dcffabd9422659c3b013ed8624c09ae90e4 (diff)
downloadnuttx-dda5be5c1fc672b5d9cb3a910b5e0cb0a41046c5.tar.gz
nuttx-dda5be5c1fc672b5d9cb3a910b5e0cb0a41046c5.tar.bz2
nuttx-dda5be5c1fc672b5d9cb3a910b5e0cb0a41046c5.zip
More changes for a kernel-mode allocator (more to be done)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5724 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/graphics')
-rw-r--r--nuttx/graphics/nxbe/nxbe_clipper.c8
-rw-r--r--nuttx/graphics/nxbe/nxbe_colormap.c7
-rw-r--r--nuttx/graphics/nxmu/nx_connect.c8
-rw-r--r--nuttx/graphics/nxmu/nx_eventhandler.c6
-rw-r--r--nuttx/graphics/nxmu/nx_kbdin.c8
-rw-r--r--nuttx/graphics/nxmu/nxfe.h4
-rw-r--r--nuttx/graphics/nxmu/nxmu_constructwindow.c8
-rw-r--r--nuttx/graphics/nxmu/nxmu_kbdin.c6
-rw-r--r--nuttx/graphics/nxsu/nx_close.c6
-rw-r--r--nuttx/graphics/nxsu/nx_open.c6
-rw-r--r--nuttx/graphics/nxsu/nx_openwindow.c6
-rw-r--r--nuttx/graphics/nxsu/nxfe.h6
-rw-r--r--nuttx/graphics/nxsu/nxsu_constructwindow.c10
13 files changed, 56 insertions, 33 deletions
diff --git a/nuttx/graphics/nxbe/nxbe_clipper.c b/nuttx/graphics/nxbe/nxbe_clipper.c
index cdbd421c0..1c33dd243 100644
--- a/nuttx/graphics/nxbe/nxbe_clipper.c
+++ b/nuttx/graphics/nxbe/nxbe_clipper.c
@@ -1,7 +1,7 @@
/****************************************************************************
* graphics/nxbe/nxbe_clipper.c
*
- * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -44,7 +44,9 @@
#include <stdlib.h>
#include <debug.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/nx/nxglib.h>
+
#include "nxbe.h"
/****************************************************************************
@@ -113,7 +115,7 @@ static inline void nxbe_pushrectangle(FAR struct nxbe_clipstack_s *stack,
int mxrects = stack->mxrects ? 2 * stack->mxrects : NX_INITIAL_STACKSIZE;
struct nxbe_cliprect_s *newstack;
- newstack = realloc(stack->stack, sizeof(struct nxbe_cliprect_s) * mxrects);
+ newstack = krealloc(stack->stack, sizeof(struct nxbe_cliprect_s) * mxrects);
if (!newstack)
{
gdbg("Failed to reallocate stack\n");
@@ -258,7 +260,7 @@ void nxbe_clipper(FAR struct nxbe_window_s *wnd,
if (stack.stack)
{
- free(stack.stack);
+ kfree(stack.stack);
}
}
diff --git a/nuttx/graphics/nxbe/nxbe_colormap.c b/nuttx/graphics/nxbe/nxbe_colormap.c
index e33877382..89e6baace 100644
--- a/nuttx/graphics/nxbe/nxbe_colormap.c
+++ b/nuttx/graphics/nxbe/nxbe_colormap.c
@@ -45,6 +45,8 @@
#include <errno.h>
#include <debug.h>
+#include <nuttx/kmalloc.h>
+
#include "nxbe.h"
/****************************************************************************
@@ -100,11 +102,12 @@ int nxbe_colormap(FAR NX_DRIVERTYPE *dev)
*/
size = 3 * CONFIG_NX_NCOLORS * sizeof(uint8_t);
- alloc = (uint8_t*)malloc(size);
+ alloc = (uint8_t*)kmalloc(size);
if (alloc == NULL)
{
return -ENOMEM;
}
+
memset(alloc, 0xff, size);
/* Then get pointers to each color table */
@@ -149,7 +152,7 @@ int nxbe_colormap(FAR NX_DRIVERTYPE *dev)
ret = dev->putcmap(dev, &cmap);
- free(alloc);
+ kfree(alloc);
return ret;
}
#endif
diff --git a/nuttx/graphics/nxmu/nx_connect.c b/nuttx/graphics/nxmu/nx_connect.c
index 4d91b54d5..2c14579ee 100644
--- a/nuttx/graphics/nxmu/nx_connect.c
+++ b/nuttx/graphics/nxmu/nx_connect.c
@@ -1,7 +1,7 @@
/****************************************************************************
* graphics/nxmu/nx_connect.c
*
- * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -47,7 +47,9 @@
#include <errno.h>
#include <debug.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/nx/nx.h>
+
#include "nxfe.h"
/****************************************************************************
@@ -130,7 +132,7 @@ NXHANDLE nx_connectinstance(FAR const char *svrmqname)
/* Allocate the NX client structure */
- conn = (FAR struct nxfe_conn_s *)zalloc(sizeof(struct nxfe_conn_s));
+ conn = (FAR struct nxfe_conn_s *)kzalloc(sizeof(struct nxfe_conn_s));
if (!conn)
{
errno = ENOMEM;
@@ -213,7 +215,7 @@ errout_with_wmq:
errout_with_rmq:
mq_close(conn->crdmq);
errout_with_conn:
- free(conn);
+ kfree(conn);
errout:
return NULL;
}
diff --git a/nuttx/graphics/nxmu/nx_eventhandler.c b/nuttx/graphics/nxmu/nx_eventhandler.c
index 944bb12d1..815f9f583 100644
--- a/nuttx/graphics/nxmu/nx_eventhandler.c
+++ b/nuttx/graphics/nxmu/nx_eventhandler.c
@@ -1,7 +1,7 @@
/****************************************************************************
* graphics/nxmu/nx_eventhandler.c
*
- * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -46,7 +46,9 @@
#include <errno.h>
#include <debug.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/nx/nx.h>
+
#include "nxfe.h"
/****************************************************************************
@@ -96,7 +98,7 @@ static inline void nx_disconnected(FAR struct nxfe_conn_s *conn)
/* And free the client structure */
- free(conn);
+ kfree(conn);
}
/****************************************************************************
diff --git a/nuttx/graphics/nxmu/nx_kbdin.c b/nuttx/graphics/nxmu/nx_kbdin.c
index b4b91298b..69d96ea91 100644
--- a/nuttx/graphics/nxmu/nx_kbdin.c
+++ b/nuttx/graphics/nxmu/nx_kbdin.c
@@ -1,7 +1,7 @@
/****************************************************************************
* graphics/nxmu/nx_kbdin.c
*
- * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -44,7 +44,9 @@
#include <errno.h>
#include <debug.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/nx/nx.h>
+
#include "nxfe.h"
#ifdef CONFIG_NX_KBD
@@ -96,7 +98,7 @@ int nx_kbdin(NXHANDLE handle, uint8_t nch, FAR const uint8_t *ch)
*/
size = sizeof(struct nxsvrmsg_kbdin_s) + nch - 1;
- outmsg = (FAR struct nxsvrmsg_kbdin_s *)malloc(size);
+ outmsg = (FAR struct nxsvrmsg_kbdin_s *)kmalloc(size);
if (!outmsg)
{
errno = ENOMEM;
@@ -115,7 +117,7 @@ int nx_kbdin(NXHANDLE handle, uint8_t nch, FAR const uint8_t *ch)
ret = nxmu_sendserver(conn, outmsg, size);
- free(outmsg);
+ kfree(outmsg);
return ret;
}
diff --git a/nuttx/graphics/nxmu/nxfe.h b/nuttx/graphics/nxmu/nxfe.h
index b9e02616c..311cedbc6 100644
--- a/nuttx/graphics/nxmu/nxfe.h
+++ b/nuttx/graphics/nxmu/nxfe.h
@@ -492,10 +492,10 @@ extern "C" {
* inheritance: The caller's window structure may include extensions that
* are not visible to NX.
*
- * NOTE: wnd must have been allocated using malloc() (or related allocators)
+ * NOTE: wnd must have been allocated using kmalloc() (or related allocators)
* Once provided to nxfe_constructwindow() that memory is owned and managed
* by NX. On certain error conditions or when the window is closed, NX will
- * free() the window.
+ * free the window.
*
* Input Parameters:
* handle - The handle returned by nx_connect
diff --git a/nuttx/graphics/nxmu/nxmu_constructwindow.c b/nuttx/graphics/nxmu/nxmu_constructwindow.c
index e5f6dcc9a..5392c28b7 100644
--- a/nuttx/graphics/nxmu/nxmu_constructwindow.c
+++ b/nuttx/graphics/nxmu/nxmu_constructwindow.c
@@ -43,7 +43,9 @@
#include <errno.h>
#include <debug.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/nx/nx.h>
+
#include "nxfe.h"
/****************************************************************************
@@ -81,10 +83,10 @@
* inheritance: The caller's window structure may include extensions that
* are not visible to NX.
*
- * NOTE: wnd must have been allocated using malloc() (or related allocators)
+ * NOTE: wnd must have been allocated using kmalloc() (or related allocators)
* Once provided to nxfe_constructwindow() that memory is owned and managed
* by NX. On certain error conditions or when the window is closed, NX will
- * free() the window.
+ * free the window.
*
* Input Parameters:
* handle - The handle returned by nx_connect
@@ -113,7 +115,7 @@ int nxfe_constructwindow(NXHANDLE handle, FAR struct nxbe_window_s *wnd,
if (!conn || !cb)
{
- free(wnd);
+ kfree(wnd);
errno = EINVAL;
return ERROR;
}
diff --git a/nuttx/graphics/nxmu/nxmu_kbdin.c b/nuttx/graphics/nxmu/nxmu_kbdin.c
index 0308c2bfa..f156a4151 100644
--- a/nuttx/graphics/nxmu/nxmu_kbdin.c
+++ b/nuttx/graphics/nxmu/nxmu_kbdin.c
@@ -44,7 +44,9 @@
#include <errno.h>
#include <debug.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/nx/nx.h>
+
#include "nxfe.h"
#ifdef CONFIG_NX_KBD
@@ -94,7 +96,7 @@ void nxmu_kbdin(FAR struct nxfe_state_s *fe, uint8_t nch, FAR uint8_t *ch)
*/
size = sizeof(struct nxclimsg_kbdin_s) + nch - 1;
- outmsg = (FAR struct nxclimsg_kbdin_s *)malloc(size);
+ outmsg = (FAR struct nxclimsg_kbdin_s *)kmalloc(size);
if (outmsg)
{
/* Give the keypad input only to the top child */
@@ -109,7 +111,7 @@ void nxmu_kbdin(FAR struct nxfe_state_s *fe, uint8_t nch, FAR uint8_t *ch)
}
(void)nxmu_sendclientwindow(fe->be.topwnd, outmsg, size);
- free(outmsg);
+ kfree(outmsg);
}
}
diff --git a/nuttx/graphics/nxsu/nx_close.c b/nuttx/graphics/nxsu/nx_close.c
index b48a2fca2..c1b9d1537 100644
--- a/nuttx/graphics/nxsu/nx_close.c
+++ b/nuttx/graphics/nxsu/nx_close.c
@@ -1,7 +1,7 @@
/****************************************************************************
* graphics/nxsu/nx_close.c
*
- * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,9 @@
#include <stdlib.h>
#include <debug.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/nx/nx.h>
+
#include "nxfe.h"
/****************************************************************************
@@ -86,6 +88,6 @@
void nx_close(NXHANDLE handle)
{
- free(handle);
+ kfree(handle);
}
diff --git a/nuttx/graphics/nxsu/nx_open.c b/nuttx/graphics/nxsu/nx_open.c
index 72a2db058..d8efcee41 100644
--- a/nuttx/graphics/nxsu/nx_open.c
+++ b/nuttx/graphics/nxsu/nx_open.c
@@ -1,7 +1,7 @@
/****************************************************************************
* graphics/nxsu/nx_open.c
*
- * Copyright (C) 2008-2010 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2010, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -45,7 +45,9 @@
#include <errno.h>
#include <debug.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/nx/nx.h>
+
#include "nxfe.h"
/****************************************************************************
@@ -195,7 +197,7 @@ NXHANDLE nx_open(FAR NX_DRIVERTYPE *dev)
/* Allocate the NX state structure */
- fe = (FAR struct nxfe_state_s *)zalloc(sizeof(struct nxfe_state_s));
+ fe = (FAR struct nxfe_state_s *)kzalloc(sizeof(struct nxfe_state_s));
if (!fe)
{
errno = ENOMEM;
diff --git a/nuttx/graphics/nxsu/nx_openwindow.c b/nuttx/graphics/nxsu/nx_openwindow.c
index 64f4ed76d..b002f1566 100644
--- a/nuttx/graphics/nxsu/nx_openwindow.c
+++ b/nuttx/graphics/nxsu/nx_openwindow.c
@@ -1,7 +1,7 @@
/****************************************************************************
* graphics/nxsu/nx_openwindow.c
*
- * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,9 @@
#include <errno.h>
#include <debug.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/nx/nx.h>
+
#include "nxfe.h"
/****************************************************************************
@@ -103,7 +105,7 @@ NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb,
/* Pre-allocate the window structure */
- wnd = (FAR struct nxbe_window_s *)zalloc(sizeof(struct nxbe_window_s));
+ wnd = (FAR struct nxbe_window_s *)kzalloc(sizeof(struct nxbe_window_s));
if (!wnd)
{
errno = ENOMEM;
diff --git a/nuttx/graphics/nxsu/nxfe.h b/nuttx/graphics/nxsu/nxfe.h
index 528224fc1..40c310d1a 100644
--- a/nuttx/graphics/nxsu/nxfe.h
+++ b/nuttx/graphics/nxsu/nxfe.h
@@ -1,7 +1,7 @@
/****************************************************************************
* graphics/nxsu/nxfe.h
*
- * Copyright (C) 2008-2010 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2010, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -103,10 +103,10 @@ EXTERN const struct nx_callback_s g_bkgdcb;
* inheritance: The caller's window structure may include extensions that
* are not visible to NX.
*
- * NOTE: wnd must have been allocated using malloc() (or related allocators)
+ * NOTE: wnd must have been allocated using kmalloc() (or related allocators)
* Once provided to nxfe_constructwindow() that memory is owned and managed
* by NX. On certain error conditions or when the window is closed, NX will
- * free() the window.
+ * free the window.
*
* Input Parameters:
* handle - The handle returned by nx_connect
diff --git a/nuttx/graphics/nxsu/nxsu_constructwindow.c b/nuttx/graphics/nxsu/nxsu_constructwindow.c
index f812b3f83..194a62106 100644
--- a/nuttx/graphics/nxsu/nxsu_constructwindow.c
+++ b/nuttx/graphics/nxsu/nxsu_constructwindow.c
@@ -1,7 +1,7 @@
/****************************************************************************
* graphics/nxsu/nx_openwindow.c
*
- * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,9 @@
#include <errno.h>
#include <debug.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/nx/nx.h>
+
#include "nxfe.h"
/****************************************************************************
@@ -81,10 +83,10 @@
* inheritance: The caller's window structure may include extensions that
* are not visible to NX.
*
- * NOTE: wnd must have been allocated using malloc() (or related allocators)
+ * NOTE: wnd must have been allocated using kmalloc() (or related allocators)
* Once provided to nxfe_constructwindow() that memory is owned and managed
* by NX. On certain error conditions or when the window is closed, NX will
- * free() the window.
+ * free the window.
*
* Input Parameters:
* handle - The handle returned by nx_connect
@@ -113,7 +115,7 @@ int nxfe_constructwindow(NXHANDLE handle, FAR struct nxbe_window_s *wnd,
if (!fe || !cb)
{
- free(wnd);
+ kfree(wnd);
errno = EINVAL;
return ERROR;
}