Added a function to the C binding to free a char* pointer

This commit is contained in:
Matt Hill
2016-10-17 22:58:43 -04:00
parent 90a4b2be0e
commit d2d07100ab
2 changed files with 13 additions and 1 deletions

View File

@@ -21,7 +21,8 @@
#include <alpr.h>
#include <string.h>
#include <vector>
#include <stdlib.h>
OPENALPRC_DLL_EXPORT OPENALPR* openalpr_init(const char* country, const char* configFile, const char* runtimeDir)
{
alpr::Alpr* alpr_inst = new alpr::Alpr(country, configFile, runtimeDir);
@@ -99,6 +100,12 @@ OPENALPRC_DLL_EXPORT char* openalpr_recognize_encodedimage(OPENALPR* instance, u
return result_obj;
}
OPENALPRC_DLL_EXPORT void openalpr_free_response_string(char* response)
{
free(response);
}
OPENALPRC_DLL_EXPORT void openalpr_cleanup(OPENALPR* instance)
{
delete ((alpr::Alpr*) instance);

View File

@@ -65,6 +65,11 @@ char* openalpr_recognize_rawimage(OPENALPR* instance, unsigned char* pixelData,
// Recognizes the encoded (e.g., JPEG, PNG) image. bytes are the raw bytes for the image data.
char* openalpr_recognize_encodedimage(OPENALPR* instance, unsigned char* bytes, long long length, struct AlprCRegionOfInterest roi);
// Frees a char* response that was provided from a recognition request.
// This is required for interoperating with managed languages (e.g., C#) that can't free the memory themselves
void openalpr_free_response_string(char* response);
// Free the memory for the OpenALPR instance created with openalpr_init
void openalpr_cleanup(OPENALPR* instance);