Commit 1ead4d2a authored by George Nash's avatar George Nash

Connect new/finalize to new/free for endpoints

This extends the endpoint struct for swig so the generated
code will call oc_new_endpoint and oc_free_endpoint when
new and finalize are called.

Endpoint(s) are set to NULL after calling oc_free_endpoint or
oc_free_server_endpoints is called from Java. This will prevent
double freeing memory which would result in a segfault.

code that returns or accept multiple endpoints in a list now
indicate that fact because the variable name is plural
'endpoints'

Change-Id: Id11a1c98e724bf44b7ab82e92a529f3859f6e936
Signed-off-by: George Nash's avatarGeorge Nash <george.nash@intel.com>
parent b473c9fa
package org.iotivity;
public interface OCDiscoveryHandler {
public OCDiscoveryFlags handler(String anchor, String uri, String[] types, int interfaceMask, OCEndpoint endpoint, int resourcePropertiesMask);
public OCDiscoveryFlags handler(String anchor, String uri, String[] types, int interfaceMask, OCEndpoint endpoints, int resourcePropertiesMask);
}
\ No newline at end of file
package org.iotivity;
public interface OCObtDiscoveryHandler {
public void handler(OCUuid uuid, OCEndpoint endpoint);
public void handler(OCUuid uuid, OCEndpoint endpoints);
}
\ No newline at end of file
......@@ -1352,10 +1352,11 @@ void jni_stop_multicast(oc_client_response_t *response) {
%ignore oc_free_server_endpoints;
%rename(freeServerEndpoints) jni_free_server_endpoints;
%inline %{
void jni_free_server_endpoints(oc_endpoint_t *endpoint) {
void jni_free_server_endpoints(oc_endpoint_t *endpoints) {
OC_DBG("JNI: - lock %s\n", __func__);
jni_mutex_lock(jni_sync_lock);
oc_free_server_endpoints(endpoint);
oc_free_server_endpoints(endpoints);
endpoints = NULL;
jni_mutex_unlock(jni_sync_lock);
OC_DBG("JNI: - unlock %s\n", __func__);
}
......
......@@ -24,6 +24,18 @@
%}
/*******************Begin oc_endpoint.h*********************/
%extend oc_endpoint_t {
oc_endpoint_t() {
OC_DBG("JNI: %s\n", __func__);
return oc_new_endpoint();
}
~oc_endpoint_t() {
OC_DBG("JNI: %s\n", __func__);
oc_free_endpoint($self);
$self = NULL;
}
}
%rename(OCEndpoint) oc_endpoint_t;
// must use the oc_endpoint_set_di function to set di.
%immutable oc_endpoint_t::di;
......@@ -42,7 +54,14 @@
%rename(interfaceIndex) interface_index;
// look into exposing oc_make_ipv4_endpoint and oc_make_ipv6_endpoint
%rename(newEndpoint) oc_new_endpoint;
%rename(freeEndpoint) oc_free_endpoint;
%ignore oc_free_endpoint;
%rename(freeEndpoint) jni_free_endpoint;
%inline %{
void jni_free_endpoint(oc_endpoint_t *endpoint) {
oc_free_endpoint(endpoint);
endpoint = NULL;
}
%}
%rename(setDi) oc_endpoint_set_di;
%ignore oc_endpoint_to_string;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment