aboutsummaryrefslogtreecommitdiffstats
path: root/main/frame.c
diff options
context:
space:
mode:
authorbbryant <bbryant@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-08 16:40:28 +0000
committerbbryant <bbryant@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-08 16:40:28 +0000
commit0110f8c87a0481038e3673640c387417fb339b4c (patch)
treedf03af827ea95734e2906e4737660d983e3e0b01 /main/frame.c
parentcdea52a3def39e3b06cb2ef6f0ca88a4c5f710a8 (diff)
Janitor project to convert sizeof to ARRAY_LEN macro.
(closes issue #13002) Reported by: caio1982 Patches: janitor_arraylen5.diff uploaded by caio1982 (license 22) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@129045 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/frame.c')
-rw-r--r--main/frame.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/main/frame.c b/main/frame.c
index f92628e28..29bf66a9d 100644
--- a/main/frame.c
+++ b/main/frame.c
@@ -503,7 +503,7 @@ struct ast_format_list *ast_get_format_list_index(int index)
struct ast_format_list *ast_get_format_list(size_t *size)
{
- *size = (sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]));
+ *size = ARRAY_LEN(AST_FORMAT_LIST);
return AST_FORMAT_LIST;
}
@@ -511,7 +511,7 @@ char* ast_getformatname(int format)
{
int x;
char *ret = "unknown";
- for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
+ for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
if (AST_FORMAT_LIST[x].bits == format) {
ret = AST_FORMAT_LIST[x].name;
break;
@@ -533,7 +533,7 @@ char *ast_getformatname_multiple(char *buf, size_t size, int format)
end += len;
size -= len;
start = end;
- for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
+ for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
if (AST_FORMAT_LIST[x].bits & format) {
snprintf(end, size,"%s|",AST_FORMAT_LIST[x].name);
len = strlen(end);
@@ -561,7 +561,7 @@ static const char *ast_expand_codec_alias(const char *in)
{
int x;
- for (x = 0; x < sizeof(ast_codec_alias_table) / sizeof(ast_codec_alias_table[0]); x++) {
+ for (x = 0; x < ARRAY_LEN(ast_codec_alias_table); x++) {
if (!strcmp(in,ast_codec_alias_table[x].alias))
return ast_codec_alias_table[x].realname;
}
@@ -573,7 +573,7 @@ int ast_getformatbyname(const char *name)
int x, all, format = 0;
all = strcasecmp(name, "all") ? 0 : 1;
- for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
+ for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
if (all ||
!strcasecmp(AST_FORMAT_LIST[x].name,name) ||
!strcasecmp(AST_FORMAT_LIST[x].name, ast_expand_codec_alias(name))) {
@@ -590,7 +590,7 @@ char *ast_codec2str(int codec)
{
int x;
char *ret = "unknown";
- for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
+ for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
if (AST_FORMAT_LIST[x].bits == codec) {
ret = AST_FORMAT_LIST[x].desc;
break;
@@ -1023,7 +1023,7 @@ void ast_codec_pref_remove(struct ast_codec_pref *pref, int format)
memcpy(&oldorder, pref, sizeof(oldorder));
memset(pref, 0, sizeof(*pref));
- for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
+ for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
slot = oldorder.order[x];
size = oldorder.framing[x];
if (! slot)
@@ -1043,7 +1043,7 @@ int ast_codec_pref_append(struct ast_codec_pref *pref, int format)
ast_codec_pref_remove(pref, format);
- for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
+ for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
if (AST_FORMAT_LIST[x].bits == format) {
newindex = x + 1;
break;
@@ -1051,7 +1051,7 @@ int ast_codec_pref_append(struct ast_codec_pref *pref, int format)
}
if (newindex) {
- for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
+ for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
if (!pref->order[x]) {
pref->order[x] = newindex;
break;
@@ -1104,7 +1104,7 @@ int ast_codec_pref_setsize(struct ast_codec_pref *pref, int format, int framems)
{
int x, index = -1;
- for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
+ for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
if (AST_FORMAT_LIST[x].bits == format) {
index = x;
break;
@@ -1128,7 +1128,7 @@ int ast_codec_pref_setsize(struct ast_codec_pref *pref, int format, int framems)
framems = AST_FORMAT_LIST[index].max_ms;
- for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
+ for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
if (pref->order[x] == (index + 1)) {
pref->framing[x] = framems;
break;
@@ -1144,7 +1144,7 @@ struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, int f
int x, index = -1, framems = 0;
struct ast_format_list fmt = { 0, };
- for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
+ for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
if (AST_FORMAT_LIST[x].bits == format) {
fmt = AST_FORMAT_LIST[x];
index = x;
@@ -1152,7 +1152,7 @@ struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, int f
}
}
- for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
+ for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
if (pref->order[x] == (index + 1)) {
framems = pref->framing[x];
break;
@@ -1182,7 +1182,7 @@ int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best)
{
int x, ret = 0, slot;
- for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
+ for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
slot = pref->order[x];
if (!slot)