[3/7] xtea: add av_xtea_alloc()

Message ID 1438032992-4680-4-git-send-email-jamrial@gmail.com
State New
Headers show

Commit Message

James Almer July 27, 2015, 9:36 p.m.
Signed-off-by: James Almer <jamrial@gmail.com>
---
 doc/APIchanges   |  1 +
 libavutil/xtea.c | 12 ++++++++++++
 libavutil/xtea.h | 10 ++++++++++
 3 files changed, 23 insertions(+)

Patch

diff --git a/doc/APIchanges b/doc/APIchanges
index 3d40ec7..be5d4cf 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -16,6 +16,7 @@  API changes, most recent first:
 2015-xx-xx - lavu 54.16.0
   xxxxxxx -  Add av_blowfish_alloc().
   xxxxxxx -  Add av_rc4_alloc().
+  xxxxxxx -  Add av_xtea_alloc().
 
 2015-xx-xx - lavc 56.35.0 - avcodec.h
   xxxxxxxxx - Rename CODEC_FLAG* defines to AV_CODEC_FLAG*.
diff --git a/libavutil/xtea.c b/libavutil/xtea.c
index 53c0bfe..c0d8b17 100644
--- a/libavutil/xtea.c
+++ b/libavutil/xtea.c
@@ -31,8 +31,20 @@ 
 #include "avutil.h"
 #include "common.h"
 #include "intreadwrite.h"
+#include "mem.h"
 #include "xtea.h"
 
+#if !FF_API_CRYPTO_CONTEXT
+typedef struct AVXTEA {
+    uint32_t key[16];
+} AVXTEA;
+#endif
+
+struct AVXTEA *av_xtea_alloc(void)
+{
+    return av_mallocz(sizeof(struct AVXTEA));
+}
+
 void av_xtea_init(AVXTEA *ctx, const uint8_t key[16])
 {
     int i;
diff --git a/libavutil/xtea.h b/libavutil/xtea.h
index 0fc3810..54ba523 100644
--- a/libavutil/xtea.h
+++ b/libavutil/xtea.h
@@ -22,6 +22,7 @@ 
 #define AVUTIL_XTEA_H
 
 #include <stdint.h>
+#include "version.h"
 
 /**
  * @file
@@ -31,9 +32,18 @@ 
  * @{
  */
 
+#if FF_API_CRYPTO_CONTEXT
 typedef struct AVXTEA {
     uint32_t key[16];
 } AVXTEA;
+#else
+struct AVXTEA;
+#endif
+
+/**
+ * Allocate an AVXTEA context.
+ */
+struct AVXTEA *av_xtea_alloc(void);
 
 /**
  * Initialize an AVXTEA context.