summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-06-26 19:57:17 +0000
committerBrian Paul <[email protected]>2005-06-26 19:57:17 +0000
commitf8582b6c1f2403869d21bf57093f644284139802 (patch)
tree0fdadcdc28aba6b44687f0d42c9b72eb97109bec /src/mesa/main
parent394fd40a536faade5ccfbbb1f2920394e89ad4aa (diff)
check for null oldBuffer in _mesa_realloc(), cleaned up some comments
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/imports.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 1972826a756..95116ca91e1 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -34,7 +34,7 @@
* Mesa 3-D graphics library
* Version: 6.3
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -146,8 +146,10 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment)
return (void *) buf;
}
-/** Same as _mesa_align_malloc(), but using _mesa_calloc() instead of
- * _mesa_malloc() */
+/**
+ * Same as _mesa_align_malloc(), but using _mesa_calloc() instead of
+ * _mesa_malloc()
+ */
void *
_mesa_align_calloc(size_t bytes, unsigned long alignment)
{
@@ -174,10 +176,9 @@ _mesa_align_calloc(size_t bytes, unsigned long alignment)
}
/**
- * Free memory allocated with _mesa_align_malloc() or _mesa_align_calloc().
- *
+ * Free memory which was allocated with either _mesa_align_malloc()
+ * or _mesa_align_calloc().
* \param ptr pointer to the memory to be freed.
- *
* The actual address to free is stored in the word immediately before the
* address the client sees.
*/
@@ -193,20 +194,20 @@ _mesa_align_free(void *ptr)
#endif
}
-/** Wrapper around either memcpy() or xf86memcpy() */
+/** Reallocate memory */
void *
_mesa_realloc(void *oldBuffer, size_t oldSize, size_t newSize)
{
const size_t copySize = (oldSize < newSize) ? oldSize : newSize;
void *newBuffer = _mesa_malloc(newSize);
- if (newBuffer && copySize > 0)
+ if (newBuffer && oldBuffer && copySize > 0)
_mesa_memcpy(newBuffer, oldBuffer, copySize);
if (oldBuffer)
_mesa_free(oldBuffer);
return newBuffer;
}
-
+/** memcpy wrapper */
void *
_mesa_memcpy(void *dest, const void *src, size_t n)
{
@@ -232,8 +233,8 @@ _mesa_memset( void *dst, int val, size_t n )
#endif
}
-/** Fill memory with a constant 16bit word.
- *
+/**
+ * Fill memory with a constant 16bit word.
* \param dst destination pointer.
* \param val value.
* \param n number of words.