release-1.10release-1.8release-1.9
Last change
on this file since 6c3d4ad was
d427f08,
checked in by Nelson Elhage <nelhage@mit.edu>, 13 years ago
|
Use G_GNUC_WARN_UNUSED_RESULT
Have gcc warn us when we ignore the result of a function that requires
the caller to free the result, or an initilization function that can
fail. This might help (slightly) with preventing leaks and segfaults.
Additionally changed some functions that should never fail to not
return values. (The owl_list_* functions changed only fail if
list->size < 0, which we assume is not the case elsewhere.)
|
-
Property mode set to
100644
|
File size:
906 bytes
|
Line | |
---|
1 | #include "owl.h" |
---|
2 | |
---|
3 | #include <assert.h> |
---|
4 | |
---|
5 | bool owl_is_editcontext(const owl_context *ctx) |
---|
6 | { |
---|
7 | return owl_context_matches(ctx, OWL_CTX_TYPWIN); |
---|
8 | } |
---|
9 | |
---|
10 | G_GNUC_WARN_UNUSED_RESULT owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata) |
---|
11 | { |
---|
12 | owl_context *ctx = owl_context_new(mode, owl_editwin_ref(e), keymap, |
---|
13 | owl_editwin_get_window(e)); |
---|
14 | ctx->deactivate_cb = deactivate_cb; |
---|
15 | ctx->delete_cb = owl_editcontext_delete_cb; |
---|
16 | ctx->cbdata = cbdata; |
---|
17 | /* TODO: the flags are really screwy. */ |
---|
18 | assert(owl_is_editcontext(ctx)); |
---|
19 | return ctx; |
---|
20 | } |
---|
21 | |
---|
22 | owl_editwin *owl_editcontext_get_editwin(const owl_context *ctx) |
---|
23 | { |
---|
24 | if (!owl_is_editcontext(ctx)) return NULL; |
---|
25 | return ctx->data; |
---|
26 | } |
---|
27 | |
---|
28 | void owl_editcontext_delete_cb(owl_context *ctx) |
---|
29 | { |
---|
30 | if (owl_is_editcontext(ctx) && ctx->data) { |
---|
31 | owl_editwin_unref(ctx->data); |
---|
32 | ctx->data = NULL; |
---|
33 | } |
---|
34 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.