Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / examples / tutorial / dlopen / reverse.cc
blob94eaaef2b6f7cabd09f284655a06af418e30eefb
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.
5 #include "reverse.h"
6 #include <stdlib.h>
7 #include <string.h>
9 extern "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;