1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Factor intdup out of smjs_get_keymap_object.

This commit is contained in:
Miciah Dashiel Butler Masters 2005-12-26 11:07:15 +00:00 committed by Miciah Dashiel Butler Masters
parent ec6e7c9044
commit 1602bd5d29
2 changed files with 15 additions and 3 deletions

View File

@ -11,6 +11,7 @@
#include "main/event.h"
#include "scripting/smjs/core.h"
#include "scripting/smjs/elinks_object.h"
#include "util/memory.h"
static JSBool
keymap_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
@ -155,11 +156,9 @@ smjs_get_keymap_object(enum keymap_id keymap_id)
if (!keymap_object) return NULL;
data = mem_alloc(sizeof(*data));
data = intdup(keymap_id);
if (!data) return NULL;
*data = keymap_id;
if (JS_FALSE != JS_SetPrivate(smjs_ctx, keymap_object, data))
return keymap_object;

View File

@ -161,4 +161,17 @@ mem_align_alloc__(
#define mem_free_if(x) mem_free_set(&x, NULL)
#endif
/* This is out of place, but there is no better place. */
static inline int *
intdup(int i)
{
int *p = mem_alloc(sizeof(*p));
if (p) *p = i;
return p;
}
#endif