summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bsd-core/drmP.h1
-rw-r--r--bsd-core/drm_memory.c5
-rw-r--r--bsd/drmP.h1
-rw-r--r--bsd/drm_memory.h5
-rw-r--r--linux-core/drmP.h1
-rw-r--r--linux-core/drm_memory.h12
-rw-r--r--linux-core/drm_memory_debug.h11
-rw-r--r--linux/drmP.h1
-rw-r--r--linux/drm_memory.h12
-rw-r--r--linux/drm_memory_debug.h11
10 files changed, 60 insertions, 0 deletions
diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h
index ff4cd895..9cd41b8d 100644
--- a/bsd-core/drmP.h
+++ b/bsd-core/drmP.h
@@ -401,6 +401,7 @@ extern int DRM(version)( DRM_IOCTL_ARGS );
extern void DRM(mem_init)(void);
extern void DRM(mem_uninit)(void);
extern void *DRM(alloc)(size_t size, int area);
+extern void *DRM(calloc)(size_t nmemb, size_t size, int area);
extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
int area);
extern void DRM(free)(void *pt, size_t size, int area);
diff --git a/bsd-core/drm_memory.c b/bsd-core/drm_memory.c
index edd9ffa6..dc0d3753 100644
--- a/bsd-core/drm_memory.c
+++ b/bsd-core/drm_memory.c
@@ -58,6 +58,11 @@ void *DRM(alloc)(size_t size, int area)
return malloc(size, DRM(M_DRM), M_NOWAIT);
}
+void *DRM(calloc)(size_t nmemb, size_t size, int area)
+{
+ return malloc(size * nmemb, DRM(M_DRM), M_NOWAIT | M_ZERO);
+}
+
void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
{
void *pt;
diff --git a/bsd/drmP.h b/bsd/drmP.h
index ff4cd895..9cd41b8d 100644
--- a/bsd/drmP.h
+++ b/bsd/drmP.h
@@ -401,6 +401,7 @@ extern int DRM(version)( DRM_IOCTL_ARGS );
extern void DRM(mem_init)(void);
extern void DRM(mem_uninit)(void);
extern void *DRM(alloc)(size_t size, int area);
+extern void *DRM(calloc)(size_t nmemb, size_t size, int area);
extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
int area);
extern void DRM(free)(void *pt, size_t size, int area);
diff --git a/bsd/drm_memory.h b/bsd/drm_memory.h
index edd9ffa6..dc0d3753 100644
--- a/bsd/drm_memory.h
+++ b/bsd/drm_memory.h
@@ -58,6 +58,11 @@ void *DRM(alloc)(size_t size, int area)
return malloc(size, DRM(M_DRM), M_NOWAIT);
}
+void *DRM(calloc)(size_t nmemb, size_t size, int area)
+{
+ return malloc(size * nmemb, DRM(M_DRM), M_NOWAIT | M_ZERO);
+}
+
void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
{
void *pt;
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index e80f7788..8a995dbe 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -817,6 +817,7 @@ extern void DRM(mem_init)(void);
extern int DRM(mem_info)(char *buf, char **start, off_t offset,
int request, int *eof, void *data);
extern void *DRM(alloc)(size_t size, int area);
+extern void *DRM(calloc)(size_t nmemb, size_t size, int area);
extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
int area);
extern void DRM(free)(void *pt, size_t size, int area);
diff --git a/linux-core/drm_memory.h b/linux-core/drm_memory.h
index 4ac7bac5..59e86b0c 100644
--- a/linux-core/drm_memory.h
+++ b/linux-core/drm_memory.h
@@ -226,6 +226,18 @@ void *DRM(alloc)(size_t size, int area)
return kmalloc(size, GFP_KERNEL);
}
+/** Wrapper around kmalloc() */
+void *DRM(calloc)(size_t size, size_t nmemb, int area)
+{
+ void *addr;
+
+ addr = kmalloc(size * nmemb, GFP_KERNEL);
+ if (addr != NULL)
+ memset((void *)addr, 0, size * nmemb);
+
+ return addr;
+}
+
/** Wrapper around kmalloc() and kfree() */
void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
{
diff --git a/linux-core/drm_memory_debug.h b/linux-core/drm_memory_debug.h
index 3ef2a05c..fae419ec 100644
--- a/linux-core/drm_memory_debug.h
+++ b/linux-core/drm_memory_debug.h
@@ -167,6 +167,17 @@ void *DRM(alloc)(size_t size, int area)
return pt;
}
+void *DRM(calloc)(size_t size, size_t nmemb, int area)
+{
+ void *addr;
+
+ addr = DRM(alloc)(nmemb * size, area);
+ if (addr != NULL)
+ memset((void *)addr, 0, size * nmemb);
+
+ return addr;
+}
+
void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
{
void *pt;
diff --git a/linux/drmP.h b/linux/drmP.h
index e80f7788..8a995dbe 100644
--- a/linux/drmP.h
+++ b/linux/drmP.h
@@ -817,6 +817,7 @@ extern void DRM(mem_init)(void);
extern int DRM(mem_info)(char *buf, char **start, off_t offset,
int request, int *eof, void *data);
extern void *DRM(alloc)(size_t size, int area);
+extern void *DRM(calloc)(size_t nmemb, size_t size, int area);
extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
int area);
extern void DRM(free)(void *pt, size_t size, int area);
diff --git a/linux/drm_memory.h b/linux/drm_memory.h
index 4ac7bac5..59e86b0c 100644
--- a/linux/drm_memory.h
+++ b/linux/drm_memory.h
@@ -226,6 +226,18 @@ void *DRM(alloc)(size_t size, int area)
return kmalloc(size, GFP_KERNEL);
}
+/** Wrapper around kmalloc() */
+void *DRM(calloc)(size_t size, size_t nmemb, int area)
+{
+ void *addr;
+
+ addr = kmalloc(size * nmemb, GFP_KERNEL);
+ if (addr != NULL)
+ memset((void *)addr, 0, size * nmemb);
+
+ return addr;
+}
+
/** Wrapper around kmalloc() and kfree() */
void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
{
diff --git a/linux/drm_memory_debug.h b/linux/drm_memory_debug.h
index 3ef2a05c..fae419ec 100644
--- a/linux/drm_memory_debug.h
+++ b/linux/drm_memory_debug.h
@@ -167,6 +167,17 @@ void *DRM(alloc)(size_t size, int area)
return pt;
}
+void *DRM(calloc)(size_t size, size_t nmemb, int area)
+{
+ void *addr;
+
+ addr = DRM(alloc)(nmemb * size, area);
+ if (addr != NULL)
+ memset((void *)addr, 0, size * nmemb);
+
+ return addr;
+}
+
void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
{
void *pt;