|
@@ -42,14 +42,39 @@
|
|
|
*/
|
|
|
|
|
|
#include "gear_config.h"
|
|
|
-#include <libgearman/common.h>
|
|
|
|
|
|
-#include "libgearman/server_options.hpp"
|
|
|
+#include "libgearman/common.h"
|
|
|
+
|
|
|
+#include <memory>
|
|
|
+
|
|
|
+bool gearman_request_option(gearman_universal_st &universal,
|
|
|
+ gearman_string_t &option)
|
|
|
+{
|
|
|
+ char* option_str_cpy = (char*) malloc(gearman_size(option));
|
|
|
+
|
|
|
+ if (option_str_cpy == NULL)
|
|
|
+ {
|
|
|
+ gearman_error(universal, GEARMAN_MEMORY_ALLOCATION_FAILURE, "malloc()");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ strncpy(option_str_cpy, gearman_c_str(option), gearman_size(option));
|
|
|
+
|
|
|
+ gearman_server_options_st *server_options = new (std::nothrow) gearman_server_options_st(universal, option_str_cpy, gearman_size(option));
|
|
|
+ if (server_options == NULL)
|
|
|
+ {
|
|
|
+ free(option_str_cpy);
|
|
|
+ gearman_error(universal, GEARMAN_MEMORY_ALLOCATION_FAILURE, "new gearman_server_options_st()");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
|
|
|
gearman_server_options_st::gearman_server_options_st(gearman_universal_st &universal_arg,
|
|
|
const char* option_arg, const size_t option_arg_size) :
|
|
|
- next(NULL), prev(NULL), option(option_arg),
|
|
|
- option_length(option_arg_size),
|
|
|
+ _option(option_arg), _option_length(option_arg_size),
|
|
|
+ next(NULL), prev(NULL),
|
|
|
universal(universal_arg)
|
|
|
{
|
|
|
if (universal.server_options_list)
|
|
@@ -62,9 +87,9 @@ gearman_server_options_st::gearman_server_options_st(gearman_universal_st &unive
|
|
|
|
|
|
gearman_server_options_st::~gearman_server_options_st()
|
|
|
{
|
|
|
- if (option)
|
|
|
+ if (_option)
|
|
|
{
|
|
|
- free((void*)option);
|
|
|
+ free((void*)_option);
|
|
|
}
|
|
|
|
|
|
{ // Remove from universal list
|