mirror of
https://github.com/javalsai/lidm.git
synced 2025-07-03 14:25:03 +02:00
format: satisfy linter
This commit is contained in:
parent
44d7836955
commit
0b02a2cef2
@ -6,6 +6,7 @@
|
||||
#include "config.h"
|
||||
#include "sessions.h"
|
||||
|
||||
bool launch(char *user, char *passwd, struct session session, void (*cb)(void), struct behavior* behavior);
|
||||
bool launch(char *user, char *passwd, struct session session, void (*cb)(void),
|
||||
struct behavior *behavior);
|
||||
|
||||
#endif
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "util.h"
|
||||
|
||||
void setup(struct config);
|
||||
int load(struct Vector * users, struct Vector * sessions);
|
||||
int load(struct Vector *users, struct Vector *sessions);
|
||||
void print_err(const char *);
|
||||
void print_errno(const char *);
|
||||
|
||||
|
@ -14,18 +14,18 @@ void read_press(u_char *, char *);
|
||||
void strcln(char **dest, const char *source);
|
||||
|
||||
struct Vector {
|
||||
uint32_t length;
|
||||
uint32_t alloc_len;
|
||||
uint16_t alloc_size;
|
||||
void** pages;
|
||||
uint32_t length;
|
||||
uint32_t alloc_len;
|
||||
uint16_t alloc_size;
|
||||
void **pages;
|
||||
};
|
||||
|
||||
struct Vector vec_new();
|
||||
int vec_push(struct Vector*, void* item);
|
||||
void vec_free(struct Vector*);
|
||||
void vec_clear(struct Vector*);
|
||||
void vec_reset(struct Vector*);
|
||||
void* vec_pop(struct Vector*); // won't free it, nor shrink vec list space
|
||||
void* vec_get(struct Vector*, size_t index);
|
||||
int vec_push(struct Vector *, void *item);
|
||||
void vec_free(struct Vector *);
|
||||
void vec_clear(struct Vector *);
|
||||
void vec_reset(struct Vector *);
|
||||
void *vec_pop(struct Vector *); // won't free it, nor shrink vec list space
|
||||
void *vec_get(struct Vector *, size_t index);
|
||||
|
||||
#endif
|
||||
|
@ -89,7 +89,7 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
|
||||
|
||||
// just add this to the list
|
||||
if (name_buf != NULL && exec_buf != NULL) {
|
||||
struct session *session_i = malloc(sizeof (struct session));
|
||||
struct session *session_i = malloc(sizeof(struct session));
|
||||
*session_i = __new_session(session_type, name_buf, exec_buf,
|
||||
tryexec_buf == NULL ? "" : tryexec_buf);
|
||||
vec_push(cb_sessions, session_i);
|
||||
|
4
src/ui.c
4
src/ui.c
@ -219,7 +219,7 @@ void ffield_cursor_focus() {
|
||||
|
||||
struct user get_current_user() {
|
||||
if (of_user.current_opt != 0)
|
||||
return *(struct user*)vec_get(gusers, of_user.current_opt - 1);
|
||||
return *(struct user *)vec_get(gusers, of_user.current_opt - 1);
|
||||
else {
|
||||
struct user custom_user;
|
||||
custom_user.shell = "/usr/bin/bash";
|
||||
@ -239,7 +239,7 @@ struct session get_current_session() {
|
||||
shell_session.exec = shell_session.name = get_current_user().shell;
|
||||
return shell_session;
|
||||
} else
|
||||
return *(struct session*)vec_get(gsessions, of_session.current_opt - 1);
|
||||
return *(struct session *)vec_get(gsessions, of_session.current_opt - 1);
|
||||
} else {
|
||||
struct session custom_session;
|
||||
custom_session.type = SHELL;
|
||||
|
15
src/util.c
15
src/util.c
@ -68,7 +68,6 @@ static int selret_magic() {
|
||||
return select(1, &set, NULL, NULL, &timeout);
|
||||
}
|
||||
|
||||
|
||||
// Vector shii
|
||||
struct Vector vec_new() {
|
||||
struct Vector vec;
|
||||
@ -76,7 +75,7 @@ struct Vector vec_new() {
|
||||
return vec;
|
||||
}
|
||||
|
||||
int vec_push(struct Vector* vec, void* item) {
|
||||
int vec_push(struct Vector *vec, void *item) {
|
||||
if (vec->length >= vec->alloc_len) {
|
||||
uint32_t new_size = vec->alloc_len + vec->alloc_size;
|
||||
void **new_location = realloc(vec->pages, vec->alloc_size);
|
||||
@ -93,33 +92,33 @@ int vec_push(struct Vector* vec, void* item) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vec_free(struct Vector* vec) {
|
||||
while(vec->length > 0)
|
||||
void vec_free(struct Vector *vec) {
|
||||
while (vec->length > 0)
|
||||
free(vec->pages[--vec->length]);
|
||||
|
||||
vec_clear(vec);
|
||||
}
|
||||
|
||||
void vec_clear(struct Vector* vec) {
|
||||
void vec_clear(struct Vector *vec) {
|
||||
free(vec->pages);
|
||||
vec_reset(vec);
|
||||
}
|
||||
|
||||
void vec_reset(struct Vector* vec) {
|
||||
void vec_reset(struct Vector *vec) {
|
||||
vec->length = 0;
|
||||
vec->alloc_len = 0;
|
||||
vec->alloc_size = 4096; // 4KiB page size?
|
||||
vec->pages = NULL;
|
||||
}
|
||||
|
||||
void* vec_pop(struct Vector* vec) {
|
||||
void *vec_pop(struct Vector *vec) {
|
||||
if (vec->length == 0)
|
||||
return NULL;
|
||||
|
||||
return vec->pages[--vec->length];
|
||||
}
|
||||
|
||||
void* vec_get(struct Vector* vec, size_t index) {
|
||||
void *vec_get(struct Vector *vec, size_t index) {
|
||||
if (index >= vec->length)
|
||||
return NULL;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user