~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/util/share.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Inkscape::Util::ptr_shared<T> - like T const *, but stronger
 
3
 *
 
4
 * Authors:
 
5
 *   MenTaLguY <mental@rydia.net>
 
6
 *
 
7
 * Copyright (C) 2006 MenTaLguY
 
8
 *
 
9
 * Released under GNU GPL, read the file 'COPYING' for more information
 
10
 */
 
11
 
 
12
#include "util/share.h"
 
13
#include <glib/gmessages.h>
 
14
 
 
15
namespace Inkscape {
 
16
namespace Util {
 
17
 
 
18
ptr_shared<char> share_string(char const *string) {
 
19
    g_return_val_if_fail(string != NULL, share_unsafe<char>(NULL));
 
20
    return share_string(string, std::strlen(string));
 
21
}
 
22
 
 
23
ptr_shared<char> share_string(char const *string, std::size_t length) {
 
24
    g_return_val_if_fail(string != NULL, share_unsafe<char>(NULL));
 
25
    char *new_string=new (GC::ATOMIC) char[length+1];
 
26
    std::memcpy(new_string, string, length);
 
27
    new_string[length] = 0;
 
28
    return share_unsafe(new_string);
 
29
}
 
30
 
 
31
}
 
32
}
 
33
 
 
34
/*
 
35
  Local Variables:
 
36
  mode:c++
 
37
  c-file-style:"stroustrup"
 
38
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
39
  indent-tabs-mode:nil
 
40
  fill-column:99
 
41
  End:
 
42
*/
 
43
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :