summaryrefslogtreecommitdiff
path: root/epan/oids_test.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-01-17 14:11:29 -0500
committerMichael Mann <mmann78@netscape.net>2015-01-19 02:52:11 +0000
commite333e4c90f0aca41b0a56cef22fd80d0b0e73e14 (patch)
tree0d90a0e8561d6e4cf1361d56629e649af655d40d /epan/oids_test.c
parent59155d1d1c40a979d5f5040e4df35ee72dadbb9c (diff)
downloadwireshark-e333e4c90f0aca41b0a56cef22fd80d0b0e73e14.tar.gz
Convert OID APIs to use wmem.
There are a few oid functions that are only called in oids_test.c. I'll presume the APIs are used in proprietary dissectors rather than just remove them. Change-Id: I4595e00f93bf9ab8cf2493fe0432b91960f55a3f Reviewed-on: https://code.wireshark.org/review/6592 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Evan Huus <eapache@gmail.com> Reviewed-by: Guy Harris <guy@alum.mit.edu> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/oids_test.c')
-rw-r--r--epan/oids_test.c131
1 files changed, 78 insertions, 53 deletions
diff --git a/epan/oids_test.c b/epan/oids_test.c
index 3a0fa7d6e3..1df68cb83d 100644
--- a/epan/oids_test.c
+++ b/epan/oids_test.c
@@ -27,7 +27,6 @@
#include <string.h>
#include <glib.h>
-#include "emem.h"
#include "oids.h"
#include "wmem/wmem.h"
@@ -82,10 +81,11 @@ oids_test_2subids_encoded(void)
guint len;
guint i;
- len = oid_encoded2subid(ex1.encoded, ex1.encoded_len, &subids);
+ len = oid_encoded2subid(NULL, ex1.encoded, ex1.encoded_len, &subids);
g_assert(len == ex1.subids_len);
for (i=0; i < len; i++)
g_assert(subids[i] == ex1.subids[i]);
+ wmem_free(NULL, subids);
}
static void
@@ -95,10 +95,11 @@ oids_test_2subids_encoded_long(void)
guint len;
guint i;
- len = oid_encoded2subid(ex3.encoded, ex3.encoded_len, &subids);
+ len = oid_encoded2subid(NULL, ex3.encoded, ex3.encoded_len, &subids);
g_assert(len == ex3.subids_len);
for (i=0; i < len; i++)
g_assert(subids[i] == ex3.subids[i]);
+ wmem_free(NULL, subids);
}
static void
@@ -108,10 +109,11 @@ oids_test_2subids_encoded_absviasub(void)
guint len;
guint i;
- len = oid_encoded2subid_sub(ex1.encoded, ex1.encoded_len, &subids, TRUE);
+ len = oid_encoded2subid_sub(NULL, ex1.encoded, ex1.encoded_len, &subids, TRUE);
g_assert(len == ex1.subids_len);
for (i=0; i < len; i++)
g_assert(subids[i] == ex1.subids[i]);
+ wmem_free(NULL, subids);
}
static void
@@ -121,10 +123,11 @@ oids_test_2subids_encoded_relviasub(void)
guint len;
guint i;
- len = oid_encoded2subid_sub(ex2rel.encoded, ex2rel.encoded_len, &subids, FALSE);
+ len = oid_encoded2subid_sub(NULL, ex2rel.encoded, ex2rel.encoded_len, &subids, FALSE);
g_assert(len == ex2rel.subids_len);
for (i=0; i < len; i++)
g_assert(subids[i] == ex2rel.subids[i]);
+ wmem_free(NULL, subids);
}
static void
@@ -159,9 +162,10 @@ oids_test_2encoded_string_simple(void)
guint8 *encoded = NULL;
guint len;
- len = oid_string2encoded(ex1.string, &encoded);
+ len = oid_string2encoded(NULL, ex1.string, &encoded);
g_assert(len == ex1.encoded_len);
g_assert(0 == memcmp(encoded, ex1.encoded, len));
+ wmem_free(NULL, encoded);
}
static void
@@ -170,9 +174,10 @@ oids_test_2encoded_string_short(void)
guint8 *encoded = NULL;
guint len;
- len = oid_string2encoded(ex4.string, &encoded);
+ len = oid_string2encoded(NULL, ex4.string, &encoded);
g_assert(len == ex4.encoded_len);
g_assert(0 == memcmp(encoded, ex4.encoded, len));
+ wmem_free(NULL, encoded);
}
static void
@@ -181,9 +186,10 @@ oids_test_2encoded_string_long(void)
guint8 *encoded = NULL;
guint len;
- len = oid_string2encoded(ex3.string, &encoded);
+ len = oid_string2encoded(NULL, ex3.string, &encoded);
g_assert(len == ex3.encoded_len);
g_assert(0 == memcmp(encoded, ex3.encoded, len));
+ wmem_free(NULL, encoded);
}
static void
@@ -192,9 +198,10 @@ oids_test_2encoded_string_tooshort(void)
guint8 *encoded = NULL;
guint len;
- len = oid_string2encoded(ex5.string, &encoded);
+ len = oid_string2encoded(NULL, ex5.string, &encoded);
g_assert(len == ex5.encoded_len);
g_assert(0 == memcmp(encoded, ex5.encoded, len));
+ wmem_free(NULL, encoded);
}
static void
@@ -203,9 +210,10 @@ oids_test_2encoded_subids_simple(void)
guint8 *encoded = NULL;
guint len;
- len = oid_subid2encoded(ex1.subids_len, ex1.subids, &encoded);
+ len = oid_subid2encoded(NULL, ex1.subids_len, ex1.subids, &encoded);
g_assert(len == ex1.encoded_len);
g_assert(0 == memcmp(encoded, ex1.encoded, len));
+ wmem_free(NULL, encoded);
}
static void
@@ -214,9 +222,10 @@ oids_test_2encoded_subids_bad(void)
guint8 *encoded = NULL;
guint len;
- len = oid_subid2encoded(ex5.subids_len, ex5.subids, &encoded);
+ len = oid_subid2encoded(NULL, ex5.subids_len, ex5.subids, &encoded);
g_assert(len == ex5.encoded_len);
g_assert(0 == memcmp(encoded, ex5.encoded, len));
+ wmem_free(NULL, encoded);
}
/* OIDS TESTING FUNCTIONS (/oids/2string/) */
@@ -224,56 +233,62 @@ oids_test_2encoded_subids_bad(void)
static void
oids_test_2string_encoded(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = oid_encoded2string(ex3.encoded, ex3.encoded_len);
+ oid = oid_encoded2string(NULL, ex3.encoded, ex3.encoded_len);
g_assert_cmpstr(oid, ==, ex3.string);
+ wmem_free(NULL, oid);
}
static void
oids_test_2string_encoded_rel(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = rel_oid_encoded2string(ex6rel.encoded, ex3.encoded_len);
+ oid = rel_oid_encoded2string(NULL, ex6rel.encoded, ex3.encoded_len);
g_assert_cmpstr(oid, ==, ex6rel.string);
+ wmem_free(NULL, oid);
}
static void
oids_test_2string_subids_abs(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = oid_subid2string(ex1.subids, ex1.subids_len);
+ oid = oid_subid2string(NULL, ex1.subids, ex1.subids_len);
g_assert_cmpstr(oid, ==, ex1.string);
+ wmem_free(NULL, oid);
}
static void
oids_test_2string_subids_rel(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = rel_oid_subid2string(ex2rel.subids, ex2rel.subids_len, FALSE);
+ oid = rel_oid_subid2string(NULL, ex2rel.subids, ex2rel.subids_len, FALSE);
g_assert_cmpstr(oid, ==, ex2rel.string);
+ wmem_free(NULL, oid);
}
static void
oids_test_2string_subids_absviarel(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = rel_oid_subid2string(ex1.subids, ex1.subids_len, TRUE);
+ oid = rel_oid_subid2string(NULL, ex1.subids, ex1.subids_len, TRUE);
g_assert_cmpstr(oid, ==, ex1.string);
+ wmem_free(NULL, oid);
}
static void
oids_test_2string_subids_relsizes(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = rel_oid_subid2string(ex6rel.subids, ex6rel.subids_len, FALSE);
+ oid = rel_oid_subid2string(NULL, ex6rel.subids, ex6rel.subids_len, FALSE);
g_assert_cmpstr(oid, ==, ex6rel.string);
+ wmem_free(NULL, oid);
}
/* OIDS TESTING FUNCTIONS (/oids/2resolved/) */
@@ -281,37 +296,41 @@ oids_test_2string_subids_relsizes(void)
static void
oids_test_2resolved_subids(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = oid_resolved(ex1.subids_len, ex1.subids);
+ oid = oid_resolved(NULL, ex1.subids_len, ex1.subids);
g_assert_cmpstr(oid, ==, ex1.resolved);
+ wmem_free(NULL, oid);
}
static void
oids_test_2resolved_encoded(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = oid_resolved_from_encoded(ex1.encoded, ex1.encoded_len);
+ oid = oid_resolved_from_encoded(NULL, ex1.encoded, ex1.encoded_len);
g_assert_cmpstr(oid, ==, ex1.resolved);
+ wmem_free(NULL, oid);
}
static void
oids_test_2resolved_encoded_rel(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = rel_oid_resolved_from_encoded(ex2rel.encoded, ex2rel.encoded_len);
+ oid = rel_oid_resolved_from_encoded(NULL, ex2rel.encoded, ex2rel.encoded_len);
g_assert_cmpstr(oid, ==, ex2rel.string);
+ wmem_free(NULL, oid);
}
static void
oids_test_2resolved_string(void)
{
- const gchar* oid;
+ gchar* oid;
- oid = oid_resolved_from_string(ex1.string);
+ oid = oid_resolved_from_string(NULL, ex1.string);
g_assert_cmpstr(oid, ==, ex1.resolved);
+ wmem_free(NULL, oid);
}
/* OIDS TESTING FUNCTIONS (/oids/2both/) */
@@ -319,34 +338,40 @@ oids_test_2resolved_string(void)
static void
oids_test_2both_subids(void)
{
- const gchar* resolved;
- const gchar* oid;
+ gchar* resolved;
+ gchar* oid;
- oid_both(ex1.subids_len, ex1.subids, &resolved, &oid);
+ oid_both(NULL, ex1.subids_len, ex1.subids, &resolved, &oid);
g_assert_cmpstr(resolved, ==, ex1.resolved);
g_assert_cmpstr(oid, ==, ex1.string);
+ wmem_free(NULL, resolved);
+ wmem_free(NULL, oid);
}
static void
oids_test_2both_encoded(void)
{
- const gchar* resolved;
- const gchar* oid;
+ gchar* resolved;
+ gchar* oid;
- oid_both_from_encoded(ex1.encoded, ex1.encoded_len, &resolved, &oid);
+ oid_both_from_encoded(NULL, ex1.encoded, ex1.encoded_len, &resolved, &oid);
g_assert_cmpstr(resolved, ==, ex1.resolved);
g_assert_cmpstr(oid, ==, ex1.string);
+ wmem_free(NULL, resolved);
+ wmem_free(NULL, oid);
}
static void
oids_test_2both_string(void)
{
- const gchar* resolved;
- const gchar* oid;
+ gchar* resolved;
+ gchar* oid;
- oid_both_from_string(ex1.string, &resolved, &oid);
+ oid_both_from_string(NULL, ex1.string, &resolved, &oid);
g_assert_cmpstr(resolved, ==, ex1.resolved);
g_assert_cmpstr(oid, ==, ex1.string);
+ wmem_free(NULL, resolved);
+ wmem_free(NULL, oid);
}
/* OIDS TESTING FUNCTIONS (/oids/2both/) */
@@ -370,11 +395,11 @@ oids_test_2struct_encoded(void)
{
guint matched;
guint left;
- guint32 *subids;
+ guint32 *subids = NULL;;
oid_info_t *st;
guint len, i;
- st = oid_get_from_encoded(ex1.encoded, ex1.encoded_len, &subids, &matched, &left);
+ st = oid_get_from_encoded(NULL, ex1.encoded, ex1.encoded_len, &subids, &matched, &left);
g_assert(matched == 1);
g_assert(left == ex1.subids_len - 1);
g_assert(st != NULL);
@@ -383,6 +408,7 @@ oids_test_2struct_encoded(void)
g_assert(len == ex1.subids_len);
for (i=0; i < len; i++)
g_assert(subids[i] == ex1.subids[i]);
+ wmem_free(NULL, subids);
}
static void
@@ -408,31 +434,34 @@ oids_test_2struct_string(void)
static void
oids_test_add_subids(void)
{
- const gchar* oid;
+ gchar* oid;
oid_add(ex7.resolved, ex7.subids_len, ex7.subids);
- oid = oid_resolved(ex7.subids_len, ex7.subids);
+ oid = oid_resolved(NULL, ex7.subids_len, ex7.subids);
g_assert_cmpstr(oid, ==, ex7.resolved);
+ wmem_free(NULL, oid);
}
static void
oids_test_add_encoded(void)
{
- const gchar* oid;
+ gchar* oid;
oid_add_from_encoded(ex7.resolved, ex7.encoded, ex7.encoded_len);
- oid = oid_resolved(ex7.subids_len, ex7.subids);
+ oid = oid_resolved(NULL, ex7.subids_len, ex7.subids);
g_assert_cmpstr(oid, ==, ex7.resolved);
+ wmem_free(NULL, oid);
}
static void
oids_test_add_string(void)
{
- const gchar* oid;
+ gchar* oid;
oid_add_from_string(ex7.resolved, ex7.string);
- oid = oid_resolved(ex7.subids_len, ex7.subids);
+ oid = oid_resolved(NULL, ex7.subids_len, ex7.subids);
g_assert_cmpstr(oid, ==, ex7.resolved);
+ wmem_free(NULL, oid);
}
int
@@ -488,7 +517,6 @@ main(int argc, char **argv)
g_test_add_func("/oids/add/encoded", oids_test_add_encoded);
g_test_add_func("/oids/add/string", oids_test_add_string);
- emem_init();
wmem_init();
test_scope = wmem_allocator_new(WMEM_ALLOCATOR_STRICT);
oids_init();
@@ -496,10 +524,7 @@ main(int argc, char **argv)
oids_cleanup();
wmem_destroy_allocator(test_scope);
wmem_cleanup();
- /*
- * This might have been a good place for a call to ep_free_all() but that is not part of the
- * public interface for emem.h
- */
+
return result;
}