mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
removed unused code; fixed memory leak
This commit is contained in:
parent
6155b03cf8
commit
da74c9cdbc
@ -1,14 +1,6 @@
|
||||
#include "webfuse_provider/impl/jsonrpc/request.h"
|
||||
#include "webfuse_provider/impl/jsonrpc/error.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
struct wfp_jsonrpc_request
|
||||
{
|
||||
int id;
|
||||
wfp_jsonrpc_send_fn * send;
|
||||
void * user_data;
|
||||
};
|
||||
|
||||
bool
|
||||
wfp_jsonrpc_is_request(
|
||||
json_t * message)
|
||||
@ -20,18 +12,3 @@ wfp_jsonrpc_is_request(
|
||||
return (json_is_integer(id) && json_is_string(method) &&
|
||||
(json_is_array(params) || json_is_object(params)));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
wfp_jsonrpc_request_dispose(
|
||||
struct wfp_jsonrpc_request * request)
|
||||
{
|
||||
free(request);
|
||||
}
|
||||
|
||||
void *
|
||||
wfp_jsonrpc_request_get_userdata(
|
||||
struct wfp_jsonrpc_request * request)
|
||||
{
|
||||
return request->user_data;
|
||||
}
|
||||
|
@ -2,34 +2,19 @@
|
||||
#define WFP_JSONRPC_REQUEST_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#else
|
||||
#include <cstdarg>
|
||||
#include <cstddef>
|
||||
using std::size_t;
|
||||
#endif
|
||||
|
||||
#include <jansson.h>
|
||||
#include "webfuse_provider/impl/jsonrpc/send_fn.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct wfp_jsonrpc_request;
|
||||
|
||||
extern bool wfp_jsonrpc_is_request(
|
||||
json_t * message);
|
||||
|
||||
extern void wfp_jsonrpc_request_dispose(
|
||||
struct wfp_jsonrpc_request * request);
|
||||
|
||||
extern void * wfp_jsonrpc_request_get_userdata(
|
||||
struct wfp_jsonrpc_request * request);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
#include "webfuse_provider/jsonrpc/mock_timer.hpp"
|
||||
|
||||
#include <libwebsockets.h>
|
||||
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
@ -48,6 +50,9 @@ namespace
|
||||
SendContext * context = reinterpret_cast<SendContext*>(user_data);
|
||||
context->is_called = true;
|
||||
context->response = request;
|
||||
|
||||
char * raw_data = request - LWS_PRE;
|
||||
free(raw_data);
|
||||
}
|
||||
|
||||
struct FinishedContext
|
||||
|
@ -1,25 +1,5 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "webfuse_provider/impl/jsonrpc/request.h"
|
||||
#include "webfuse_provider/status.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
struct Context
|
||||
{
|
||||
json_t * response;
|
||||
};
|
||||
|
||||
void jsonrpc_send(
|
||||
json_t * request,
|
||||
void * user_data)
|
||||
{
|
||||
Context * context = reinterpret_cast<Context*>(user_data);
|
||||
context->response = request;
|
||||
json_incref(request);
|
||||
}
|
||||
|
||||
}
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(wfp_jsonrpc_request, is_request_object_params)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user