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:
parent
ec6e7c9044
commit
1602bd5d29
@ -11,6 +11,7 @@
|
|||||||
#include "main/event.h"
|
#include "main/event.h"
|
||||||
#include "scripting/smjs/core.h"
|
#include "scripting/smjs/core.h"
|
||||||
#include "scripting/smjs/elinks_object.h"
|
#include "scripting/smjs/elinks_object.h"
|
||||||
|
#include "util/memory.h"
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
keymap_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
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;
|
if (!keymap_object) return NULL;
|
||||||
|
|
||||||
data = mem_alloc(sizeof(*data));
|
data = intdup(keymap_id);
|
||||||
if (!data) return NULL;
|
if (!data) return NULL;
|
||||||
|
|
||||||
*data = keymap_id;
|
|
||||||
|
|
||||||
if (JS_FALSE != JS_SetPrivate(smjs_ctx, keymap_object, data))
|
if (JS_FALSE != JS_SetPrivate(smjs_ctx, keymap_object, data))
|
||||||
return keymap_object;
|
return keymap_object;
|
||||||
|
|
||||||
|
@ -161,4 +161,17 @@ mem_align_alloc__(
|
|||||||
#define mem_free_if(x) mem_free_set(&x, NULL)
|
#define mem_free_if(x) mem_free_set(&x, NULL)
|
||||||
#endif
|
#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
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user