Fix all include location, and drop versions of the library that were never shipped.
[awesomized/libmemcached] / clients / memcp.cc
index 5422aa7386cbbe7a4b9f36a1bc31ba2a37647b5f..4ad0919d008a540d763cea73718c71762aa1a7fe 100644 (file)
@@ -1,4 +1,5 @@
 /* LibMemcached
+ * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/
  * Copyright (C) 2006-2009 Brian Aker
  * All rights reserved.
  *
@@ -30,7 +31,7 @@
 #include <unistd.h>
 
 
-#include <libmemcached/memcached.h>
+#include <libmemcached-1.0/memcached.h>
 
 #include "client_options.h"
 #include "utilities.h"
@@ -207,6 +208,7 @@ int main(int argc, char *argv[])
     if ((file_buffer_ptr= (char *)malloc(sizeof(char) * (size_t)sbuf.st_size)) == NULL)
     {
       std::cerr << "Error allocating file buffer(" << strerror(errno) << ")" << std::endl;
+      close(fd);
       exit(EXIT_FAILURE);
     }
 
@@ -214,12 +216,14 @@ int main(int argc, char *argv[])
     if ((read_length= ::read(fd, file_buffer_ptr, (size_t)sbuf.st_size)) == -1)
     {
       std::cerr << "Error while reading file " << file_buffer_ptr << " (" << strerror(errno) << ")" << std::endl;
+      close(fd);
       exit(EXIT_FAILURE);
     }
 
     if (read_length != sbuf.st_size)
     {
       std::cerr << "Failure while reading file. Read length was not equal to stat() length" << std::endl;
+      close(fd);
       exit(EXIT_FAILURE);
     }
 
@@ -245,7 +249,7 @@ int main(int argc, char *argv[])
 
     if (memcached_failed(rc))
     {
-      std::cerr << "Error occrrured during operation: " << memcached_last_error_message(memc) << std::endl;
+      std::cerr << "Error occrrured during memcached_set(): " << memcached_last_error_message(memc) << std::endl;
       exit_code= EXIT_FAILURE;
     }
 
@@ -254,6 +258,11 @@ int main(int argc, char *argv[])
     optind++;
   }
 
+  if (opt_verbose)
+  {
+    std::cout << "Calling memcached_free()" << std::endl;
+  }
+
   memcached_free(memc);
 
   if (opt_servers)