summaryrefslogtreecommitdiff
path: root/libavformat/concat.c
diff options
context:
space:
mode:
authorGabriel Dume <gabriel.ddx84@gmail.com>2014-09-23 10:29:57 -0400
committerDiego Biurrun <diego@biurrun.de>2014-09-25 01:44:31 -0700
commit95d312d6c82e7485f43c3ddda0f369af0e41c83b (patch)
tree7c9c3d1a7f861871506772697e42d16ec31b1005 /libavformat/concat.c
parent28f5cd312c9da9072108edf8b7685d009374ea96 (diff)
concat: K&R formatting cosmetics
Signed-off-by: Diego Biurrun <diego@biurrun.de>
Diffstat (limited to 'libavformat/concat.c')
-rw-r--r--libavformat/concat.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/libavformat/concat.c b/libavformat/concat.c
index 416bbf5fc3..2fb3ba9059 100644
--- a/libavformat/concat.c
+++ b/libavformat/concat.c
@@ -21,9 +21,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "avformat.h"
#include "libavutil/avstring.h"
#include "libavutil/mem.h"
+
+#include "avformat.h"
#include "url.h"
#define AV_CAT_SEPARATOR "|"
@@ -59,24 +60,26 @@ static av_cold int concat_open(URLContext *h, const char *uri, int flags)
char *node_uri = NULL;
int err = 0;
int64_t size;
- size_t len, i;
+ size_t len, i;
URLContext *uc;
struct concat_data *data = h->priv_data;
struct concat_nodes *nodes;
av_strstart(uri, "concat:", &uri);
- for (i = 0, len = 1; uri[i]; i++)
- if (uri[i] == *AV_CAT_SEPARATOR)
+ for (i = 0, len = 1; uri[i]; i++) {
+ if (uri[i] == *AV_CAT_SEPARATOR) {
/* integer overflow */
if (++len == UINT_MAX / sizeof(*nodes)) {
av_freep(&h->priv_data);
return AVERROR(ENAMETOOLONG);
}
+ }
+ }
- if (!(nodes = av_realloc(NULL, sizeof(*nodes) * len))) {
+ if (!(nodes = av_realloc(NULL, sizeof(*nodes) * len)))
return AVERROR(ENOMEM);
- } else
+ else
data->nodes = nodes;
/* handle input */
@@ -87,8 +90,8 @@ static av_cold int concat_open(URLContext *h, const char *uri, int flags)
len = strcspn(uri, AV_CAT_SEPARATOR);
if ((err = av_reallocp(&node_uri, len + 1)) < 0)
break;
- av_strlcpy(node_uri, uri, len+1);
- uri += len + strspn(uri+len, AV_CAT_SEPARATOR);
+ av_strlcpy(node_uri, uri, len + 1);
+ uri += len + strspn(uri + len, AV_CAT_SEPARATOR);
/* creating URLContext */
if ((err = ffurl_open(&uc, node_uri, flags,
@@ -123,16 +126,17 @@ static int concat_read(URLContext *h, unsigned char *buf, int size)
int result, total = 0;
struct concat_data *data = h->priv_data;
struct concat_nodes *nodes = data->nodes;
- size_t i = data->current;
+ size_t i = data->current;
while (size > 0) {
result = ffurl_read(nodes[i].uc, buf, size);
if (result < 0)
return total ? total : result;
- if (!result)
+ if (!result) {
if (i + 1 == data->length ||
ffurl_seek(nodes[++i].uc, 0, SEEK_SET) < 0)
break;
+ }
total += result;
buf += result;
size -= result;
@@ -150,9 +154,7 @@ static int64_t concat_seek(URLContext *h, int64_t pos, int whence)
switch (whence) {
case SEEK_END:
- for (i = data->length - 1;
- i && pos < -nodes[i].size;
- i--)
+ for (i = data->length - 1; i && pos < -nodes[i].size; i--)
pos += nodes[i].size;
break;
case SEEK_CUR: