1// Copyright (c) 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "reverse.h" 6#include <stdlib.h> 7#include <string.h> 8 9extern "C" char* Reverse(const char* s) { 10 size_t len = strlen(s); 11 char* reversed = static_cast<char*>(malloc(len + 1)); 12 for (int i = len - 1; i >= 0; --i) 13 reversed[len - i - 1] = s[i]; 14 reversed[len] = 0; 15 return reversed; 16} 17