BRL-CAD
debugmem.c
Go to the documentation of this file.
1 /* D E B U G M E M . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2008-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @file libged/debugmem.c
21  *
22  * The debugmem command.
23  *
24  */
25 
26 #include "common.h"
27 
28 #include <stdlib.h>
29 #include <ctype.h>
30 #include <string.h>
31 
32 #include "./ged_private.h"
33 
34 
35 int
36 ged_debugmem(struct ged *gedp, int argc, const char *argv[])
37 {
39  GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
40 
41  /* initialize result */
42  bu_vls_trunc(gedp->ged_result_str, 0);
43 
44  if (argc != 1) {
45  bu_vls_printf(gedp->ged_result_str, "Usage: %s", argv[0]);
46  return GED_ERROR;
47  }
48 
49  bu_prmem("Invoked via libged");
50 
51  return GED_OK;
52 }
53 
54 
55 int
56 ged_memprint(struct ged *gedp, int argc, const char *argv[])
57 {
59  GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
60 
61  /* initialize result */
62  bu_vls_trunc(gedp->ged_result_str, 0);
63 
64  if (argc != 1) {
65  bu_vls_printf(gedp->ged_result_str, "Usage: %s", argv[0]);
66  return GED_ERROR;
67  }
68 
69  bu_log("Database free-storage map:\n");
70  rt_memprint(&(gedp->ged_wdbp->dbip->dbi_freep));
71 
72  return GED_OK;
73 }
74 
75 
76 /*
77  * Local Variables:
78  * tab-width: 8
79  * mode: C
80  * indent-tabs-mode: t
81  * c-file-style: "stroustrup"
82  * End:
83  * ex: shiftwidth=4 tabstop=8
84  */
#define GED_OK
Definition: ged.h:55
void bu_log(const char *,...) _BU_ATTR_PRINTF12
Definition: log.c:176
int ged_memprint(struct ged *gedp, int argc, const char *argv[])
Definition: debugmem.c:56
void bu_prmem(const char *str)
Definition: malloc.c:516
Definition: ged.h:338
struct db_i * dbip
Definition: raytrace.h:1266
void bu_vls_trunc(struct bu_vls *vp, int len)
Definition: vls.c:198
#define GED_CHECK_ARGC_GT_0(_gedp, _argc, _flags)
Definition: ged.h:202
int ged_debugmem(struct ged *gedp, int argc, const char *argv[])
Definition: debugmem.c:36
struct rt_wdb * ged_wdbp
Definition: ged.h:340
Header file for the BRL-CAD common definitions.
#define GED_ERROR
Definition: ged.h:61
#define GED_CHECK_DATABASE_OPEN(_gedp, _flags)
Definition: ged.h:114
struct mem_map * dbi_freep
PRIVATE: map of free granules.
Definition: raytrace.h:819
struct bu_vls * ged_result_str
Definition: ged.h:357
void bu_vls_printf(struct bu_vls *vls, const char *fmt,...) _BU_ATTR_PRINTF23
Definition: vls.c:694
void rt_memprint(struct mem_map **pp)
Definition: memalloc.c:337