Changeset View
Changeset View
Standalone View
Standalone View
src/alkvalue.cpp
1 | /*************************************************************************** | 1 | /*************************************************************************** | ||
---|---|---|---|---|---|
2 | * Copyright 2010 Thomas Baumgart ipwizard@users.sourceforge.net * | 2 | * Copyright 2010 Thomas Baumgart tbaumgart@kde.org * | ||
3 | * Copyright 2018 Thomas Baumgart tbaumgart@kde.org * | ||||
3 | * * | 4 | * * | ||
4 | * This file is part of libalkimia. * | 5 | * This file is part of libalkimia. * | ||
5 | * * | 6 | * * | ||
6 | * libalkimia is free software; you can redistribute it and/or * | 7 | * libalkimia is free software; you can redistribute it and/or * | ||
7 | * modify it under the terms of the GNU Lesser General Public License * | 8 | * modify it under the terms of the GNU Lesser General Public License * | ||
8 | * as published by the Free Software Foundation; either version 2.1 of * | 9 | * as published by the Free Software Foundation; either version 2.1 of * | ||
9 | * the License or (at your option) version 3 or any later version. * | 10 | * the License or (at your option) version 3 or any later version. * | ||
10 | * * | 11 | * * | ||
Show All 30 Lines | 41 | { | |||
41 | char *p = 0; | 42 | char *p = 0; | ||
42 | // use the gmp provided conversion routine | 43 | // use the gmp provided conversion routine | ||
43 | gmp_asprintf(&p, "%Qd", val.get_mpq_t()); | 44 | gmp_asprintf(&p, "%Qd", val.get_mpq_t()); | ||
44 | 45 | | |||
45 | // convert it into a QString | 46 | // convert it into a QString | ||
46 | QString result = QString::fromLatin1(p); | 47 | QString result = QString::fromLatin1(p); | ||
47 | 48 | | |||
48 | // and free up the resources allocated by gmp_asprintf | 49 | // and free up the resources allocated by gmp_asprintf | ||
49 | __gmp_freefunc_t freefunc; | 50 | void (*freefunc) (void *, size_t); | ||
habacker: Does this need to be defined different for each variant ? | |||||
tbaumgart: No. | |||||
50 | mp_get_memory_functions(NULL, NULL, &freefunc); | 51 | mp_get_memory_functions(NULL, NULL, &freefunc); | ||
51 | (*freefunc)(p, std::strlen(p) + 1); | 52 | (*freefunc)(p, std::strlen(p) + 1); | ||
52 | 53 | | |||
53 | if (!result.contains(QLatin1Char('/'))) { | 54 | if (!result.contains(QLatin1Char('/'))) { | ||
54 | result += QString::fromLatin1("/1"); | 55 | result += QString::fromLatin1("/1"); | ||
55 | } | 56 | } | ||
56 | 57 | | |||
57 | // done | 58 | // done | ||
▲ Show 20 Lines • Show All 499 Lines • Show Last 20 Lines |
Does this need to be defined different for each variant ?