Debian Codegraph @

src/alt/range2random_glib.c

raw
1 /*
2 * Copyright (C) 2016 Jan Pokorny <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19 #include <assert.h>
20 #include <stdlib.h>
21
22 #include <glib.h>
23
24 #include "range2random_glib.h"
25 #include "ticket.h"
26
27 int
28 alt_glib_rand_from_interval(int from, int to)
29 {
30 assert(from >= 0 && from < to);
31 assert(sizeof(to) <= sizeof(gint32) || (to < 0x7fffffff));
32 return (int) g_random_int_range(from, to);
33 }