- if ((key_length > MEMCACHED_PREFIX_KEY_MAX_SIZE -1)
- || (strncpy(ptr->prefix_key, key, MEMCACHED_PREFIX_KEY_MAX_SIZE) == NULL))
- {
- ptr->prefix_key_length= 0;
- return MEMCACHED_BAD_KEY_PROVIDED;
- }
- else
- {
- ptr->prefix_key_length= key_length;
- }
+ if ((key_length > MEMCACHED_PREFIX_KEY_MAX_SIZE -1))
+ return memcached_set_error(ptr, MEMCACHED_KEY_TOO_BIG, NULL);
+
+ memcached_array_free(ptr->prefix_key);
+ ptr->prefix_key= memcached_strcpy(ptr, (const char *)data, strlen((const char*)data));
+
+ f (! ptr->prefix_key)
+ return memcached_set_error(ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, NULL);