mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-05-26 23:36:16 +00:00
refactoring
This commit is contained in:
1
janus/src/uslibs/memsinksh.c
Symbolic link
1
janus/src/uslibs/memsinksh.c
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../../src/libs/memsinksh.c
|
||||||
1
python/src/uslibs/memsinksh.c
Symbolic link
1
python/src/uslibs/memsinksh.c
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../../src/libs/memsinksh.c
|
||||||
48
src/libs/memsinksh.c
Normal file
48
src/libs/memsinksh.c
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
# #
|
||||||
|
# uStreamer - Lightweight and fast MJPEG-HTTP streamer. #
|
||||||
|
# #
|
||||||
|
# Copyright (C) 2018-2023 Maxim Devaev <mdevaev@gmail.com> #
|
||||||
|
# #
|
||||||
|
# This program is free software: you can redistribute it and/or modify #
|
||||||
|
# it under the terms of the GNU General Public License as published by #
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or #
|
||||||
|
# (at your option) any later version. #
|
||||||
|
# #
|
||||||
|
# This program is distributed in the hope that it will be useful, #
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||||
|
# GNU General Public License for more details. #
|
||||||
|
# #
|
||||||
|
# You should have received a copy of the GNU General Public License #
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||||
|
# #
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "memsinksh.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
|
||||||
|
us_memsink_shared_s *us_memsink_shared_map(int fd) {
|
||||||
|
us_memsink_shared_s *mem = mmap(
|
||||||
|
NULL,
|
||||||
|
sizeof(us_memsink_shared_s),
|
||||||
|
PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||||
|
fd, 0);
|
||||||
|
if (mem == MAP_FAILED) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
assert(mem != NULL);
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
|
||||||
|
int us_memsink_shared_unmap(us_memsink_shared_s *mem) {
|
||||||
|
assert(mem != NULL);
|
||||||
|
return munmap(mem, sizeof(us_memsink_shared_s));
|
||||||
|
}
|
||||||
@@ -22,8 +22,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <sys/mman.h>
|
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -62,23 +60,5 @@ typedef struct {
|
|||||||
} us_memsink_shared_s;
|
} us_memsink_shared_s;
|
||||||
|
|
||||||
|
|
||||||
INLINE us_memsink_shared_s *us_memsink_shared_map(int fd) {
|
us_memsink_shared_s *us_memsink_shared_map(int fd);
|
||||||
us_memsink_shared_s *mem = mmap(
|
int us_memsink_shared_unmap(us_memsink_shared_s *mem);
|
||||||
NULL,
|
|
||||||
sizeof(us_memsink_shared_s),
|
|
||||||
PROT_READ | PROT_WRITE,
|
|
||||||
MAP_SHARED,
|
|
||||||
fd,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
if (mem == MAP_FAILED) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
assert(mem != NULL);
|
|
||||||
return mem;
|
|
||||||
}
|
|
||||||
|
|
||||||
INLINE int us_memsink_shared_unmap(us_memsink_shared_s *mem) {
|
|
||||||
assert(mem != NULL);
|
|
||||||
return munmap(mem, sizeof(us_memsink_shared_s));
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user