summaryrefslogtreecommitdiff
path: root/libavutil/md5.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2012-10-11 15:08:04 +0300
committerMartin Storsjö <martin@martin.st>2012-10-11 23:35:27 +0300
commit9a92aea27bad2f5603ca85e0d0716c679a6b686c (patch)
treea38dae27b4c15cc4a75c0a3745351b8c5b3fd122 /libavutil/md5.c
parentfb32f31af76ce784c86c59c86c28e5653e223610 (diff)
avutil: Add functions for allocating opaque contexts for algorithms
The current API where the plain size is exposed is not of much use - in most cases it is allocated dynamically anyway. If allocated e.g. on the stack via an uint8_t array, there's no guarantee that the struct's members are aligned properly (unless the array is overallocated and the opaque pointer within it manually aligned to some unspecified alignment). Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavutil/md5.c')
-rw-r--r--libavutil/md5.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libavutil/md5.c b/libavutil/md5.c
index ca0e598d2e..93a91d7812 100644
--- a/libavutil/md5.c
+++ b/libavutil/md5.c
@@ -34,6 +34,7 @@
#include "bswap.h"
#include "intreadwrite.h"
#include "md5.h"
+#include "mem.h"
typedef struct AVMD5{
uint64_t len;
@@ -41,7 +42,14 @@ typedef struct AVMD5{
uint32_t ABCD[4];
} AVMD5;
+#if FF_API_CONTEXT_SIZE
const int av_md5_size = sizeof(AVMD5);
+#endif
+
+struct AVMD5 *av_md5_alloc(void)
+{
+ return av_mallocz(sizeof(struct AVMD5));
+}
static const uint8_t S[4][4] = {
{ 7, 12, 17, 22 }, /* round 1 */