Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [pointers]

In computer science, a pointer is a programming language data type whose value refers directly to (or "points to") another value stored elsewhere in the computer memory using its address.

Filter by
Sorted by
Tagged with
-2 votes
0 answers
27 views

Libsodium Encrypt using API methods and pointers [closed]

As I have not found a code snippet to use libsodium with pointers, I would like to ask whether there are memory leaks in the code below or if anything else is wrong. ...
John's user avatar
  • 97
3 votes
1 answer
82 views

Compare and merge sets from unstructured variables for automatic differentiation

I have developed an automatic differentiation module for my software. Usually AD comes in two forms; forward mode or reverse mode and very clever approaches, beyond me, might mix both. Typically the ...
Attack68's user avatar
  • 545
4 votes
1 answer
160 views

Trie implementation using std::shared_ptr

I've implemented a basic Trie that is supposed to work only with lowercase English letters. ...
csmathhc's user avatar
  • 153
2 votes
2 answers
269 views

Optimizing Subarray Removal: Can the Removal Process be Enhanced for Better Efficiency?

The only requirement is that it has to be done by pointers: And it returns the amount of removed numbers because of the way of output that is set in the main. The function, using exclusively pointer ...
eminbihh's user avatar
8 votes
3 answers
2k views

"Smart" (ish) pointer in C

I am a programmer with a primarily Rust-based background who has nonetheless taken an interest in C lately due to its simplicity and minimalism. However, one of the things I miss most from Rust is ...
JS4137's user avatar
  • 205
4 votes
1 answer
96 views

Member (virtual or not) function to C callback by generating static version at compile time

I've started to write a header-only implementation of callback for member functions : ...
hl037_'s user avatar
  • 141
1 vote
3 answers
210 views

A shared pointer which can delete the managed object before the usage count reaches zero

When I was working on my game engine, I needed to know if a game object has been destroyed or not. So, I decided to use std::shared_ptr. But the standard shared ...
LooksForFuture's user avatar
2 votes
2 answers
434 views

C++ std::shared_ptr implementation

Took a shot at implementing std::shared_ptr, with a thread-safe refcount and weak count. Didn't do weak_ptr, I'm doing this for ...
jdav22's user avatar
  • 361
4 votes
2 answers
322 views

A memory leak-free RAII wrapper around two raw pointers

As a practice of implementing RAII-enabled class, I prepared a class called DynamicWallet that wraps around two raw pointers. I am well aware that using smart ...
D.J. Elkind's user avatar
2 votes
0 answers
48 views

Reusable storage for array of objects V4

Here is a thirdfollow up on Reusable storage for array of objects, Reusable storage for array of objects V2 and Reusable storage for array of objects V3, taking into account the provided answers. The ...
Oersted's user avatar
  • 337
1 vote
1 answer
48 views

Reusable storage for array of objects V3

Here is a second follow up on Reusable storage for array of objects and Reusable storage for array of objects V2, taking into account the provided answers. The following code should be compliant at ...
Oersted's user avatar
  • 337
3 votes
1 answer
66 views

Reusable storage for array of objects V2

Here is a follow up on Reusable storage for array of objects, taking into account the provided answers. The following code should be compliant at least with gcc, <...
Oersted's user avatar
  • 337
4 votes
2 answers
487 views

Reusable storage for array of objects

My goal is to have a memory pool non-template class that is used to store arrays of objects. The same memory pool object must be reusable for a different array (difference size, different type and/or ...
Oersted's user avatar
  • 337
5 votes
2 answers
210 views

C++ UniquePtr Implementation

Took a shot at implementing std::unique_ptr. Code: ...
jdav22's user avatar
  • 361
7 votes
2 answers
203 views

shared_ptr implementation code - first cut

I've written an implementation of shared_ptr. It doesn't support weak_ptr (yet) but below is the code. I'd appreciate any feedback, comments. ...
Greg's user avatar
  • 71
2 votes
3 answers
113 views

Exercises 5.1 from K&R (function to read an integer value)

As written [above], getint treats a + or - not followed by a digit as a valid representation ...
igor's user avatar
  • 21
7 votes
3 answers
207 views

C++ String Class Reimplementation

I started learning C++ about a week ago and I was hoping somebody can critique my code. I decided to implement my own basic String class just for the sake of applying all that I've learned about ...
Janriz Libres's user avatar
3 votes
1 answer
154 views

Implementing The Decorator Design Pattern in C++

I recently tried to implement the decorator design pattern in C++. Here is the code in full: ...
Sc2046's user avatar
  • 33
-1 votes
1 answer
289 views

Copying allocated data into std::map in a smart way [closed]

I come across a problem and I solved it. The solution works but I have some feelings that there is something wrong with my solution/code. To be clear, let's assume that cars on the race track transmit ...
unique's user avatar
  • 153
7 votes
2 answers
215 views

simple connect four game

I made a simple connect four terminal game in C and was wondering if I could get feedback on it. I mainly want to know where pointers could have optimised my code, and if there are any major ...
Willem's user avatar
  • 71
4 votes
1 answer
125 views

C# wrapper that binds to Rust FFI, for the purpose of running CavalierContours functions in Unity

I have attempted to write c# bindings for a Rust library. I have never worked with unmanned code / languages before. Superficially this code does work with no apparent bugs or memory leaks. I want to ...
arcadeperfect's user avatar
5 votes
1 answer
328 views

Port Node and TreeBuilder from Python to C++

I am trying to port a TreeBuilder Python class to C++, keeping the structure as close as possible to the original. Here is a simplified Python version: https://onlinegdb.com/I4dg0hCtg The purpose of ...
Paolo's user avatar
  • 63
6 votes
3 answers
2k views

Implementation of a shared pointer constructors and destructor

I am writing my simple shared pointer. I am asking to review existing functions (understand that my implementations is not full, e.g now operator*) Review please ...
mascai's user avatar
  • 379
5 votes
1 answer
901 views

Dynamic array type using void pointers C

I made my own dynamic array type using void pointers. I'd like to know what you think of my implementation. void pointers are nice but I fear they may be inefficient. The compiler cannot tell what ...
Lead Vaxeral's user avatar
12 votes
10 answers
3k views

Trim leading/trailing space in a string

I'm practicing C and wrote a function to trim leading/trailing spaces in a string: ...
roadsidejesus's user avatar
8 votes
1 answer
880 views

Rust: Splitting a mutable slice into disjoint, but non-contiguous subslices

For some context, this is inspired by my attempt to solve this SO question. I have a mutably borrowed slice representing a 2D array, and I want to split the borrow such that I can access all the rows ...
FZs's user avatar
  • 183
0 votes
1 answer
140 views

Readlines abstraction for Golang

I've just started learning Golang and was solving some problems which required me to read lines of text from a file. I decided to abstract away the reading part so that I can use Go's ...
smac89's user avatar
  • 1,499
3 votes
1 answer
282 views

C void* Generic Hash Table

Some time ago I tried to make a generic linked list in pure C (no external libraries, only the C standard library) using void*s here. Building on top of that and ...
404 Name Not Found's user avatar
2 votes
1 answer
257 views

Intrusive smart pointer implementation

I have homework in college to implement intrusive smart pointers. ...
Edziju's user avatar
  • 319
8 votes
1 answer
681 views

C void* Generic Linked List

I once tried to make a generic linked list in pure C (no external libraries, only the C standard library) here using C macros. With the same restrictions as in the previous attempt, this time I'm ...
404 Name Not Found's user avatar
1 vote
1 answer
40 views

Moveable Points - Update variable without Re-referencing variable? Event Subscriptions? (C#, Unity)

So I have this helper script that I use to move points around manually while debugging: ...
FaffyWaffles's user avatar
1 vote
1 answer
115 views

Class that can only be created and deleter through smart pointer

I would like to expose a nullable referance of a "mesh" object, so I am returning a const pointer. However, I explicitly want to prevent anyone handling this from deleting the object. The ...
Jay's user avatar
  • 214
4 votes
1 answer
475 views

Simple slab allocator in C

Here is the plan: a slab takes up 1 page and it has PGSIZE / blocksize amount of blocks the minimum blocksize is 8 bytes, otherwise the pointer to the next block ...
runningupthatroad's user avatar
2 votes
1 answer
431 views

C Program - Camel Case (creates or splits camel case variables, methods and class names.)

I have written a program in C, which does the following operations: creates or splits Camel Case variable, method, class names. Input format Each line of the input file will begin with an operation ...
jr.çhåvez__07's user avatar
2 votes
0 answers
69 views

Virtual memory manager, physical memory manager and buddy allocator

I'm writing memory manager for my toy operating system and I would like to get some feedback. There is physical memory manager, which uses bitmap, virtual memory manager which uses buddy algorithm for ...
Mateusz's user avatar
  • 21
2 votes
1 answer
167 views

Function to find the first pair where the sum zero. using 2-pointers approach

Here is the function called sumZero, where it should return the sum of any two numbers in the array to sum upto zero. where the array is a sorted array. My approach: Using 2 pointers approach, calling ...
RONE's user avatar
  • 131
3 votes
3 answers
766 views

C program that splits the string based on a character

I tried and made a program using my beginner knowledge of C to split a string into multiple sub strings. I just wondered how languages like Python and Javascript implemented the ...
Diwas10's user avatar
  • 111
2 votes
2 answers
5k views

A simple logging library in C

I've created a simple logging library in C which I can use in my other projects. I wanted to get started in software development using the C language, and this is my first attempt at writing something ...
Vedant Jadhav's user avatar
2 votes
1 answer
467 views

Storing (and retrieving) functions by indexing them by address

I want to implement a "service" of callbacks, where subscribers register or unregister a callback. I was thinking about indexing the callbacks by the function address, so that to unregister ...
Antonio's user avatar
  • 133
1 vote
3 answers
183 views

Binary Search Tree that allows for duplicate elements - C++

I've recently made an attempt at creating a binary search tree class that allows for duplicate elements. I've included as many functions as I can think of so that I can use it later on. I've tested ...
Anthony Seager's user avatar
3 votes
1 answer
79 views

display processes children

The following program uses a parent program to determine the PIDs of multiple child processes. A function is called to return them to a dynamic vector (with the children's pids, but also the elements ...
Mike's user avatar
  • 299
1 vote
0 answers
581 views

Inheriting from a JSON converter class with schema definition through constructor

I wanted to convert C++ data structures to JSON with little code. More specifically, I wanted to convert C++ data structures to nlohmann JSON representation. Project context: The goal is to use this ...
RicardoO's user avatar
0 votes
2 answers
465 views

Slice function for C

I am trying to create a non-generic slice function. I want a 'view' not a copy. The scan_from arg is so that successive calls ...
A T's user avatar
  • 485
2 votes
1 answer
152 views

std::unique_ptr adapter class template for libgit2 objects

I'm working on a personal project to build an open-source gui for git. I'm hoping to learn a lot from the project, and maybe produce something useful for folks as I do. I'm making use of libgit2 to ...
Stephen Hern's user avatar
1 vote
2 answers
300 views

Improvement suggestions to my shared_ptr and weak_ptr implementations

Below is the entire code. I appreciate if, someone with more C++ experience can suggest if this can be improved further and if you notice any issues. controlblock.hpp ...
Albin M's user avatar
  • 135
13 votes
1 answer
1k views

Low Level VBA Hacking - making Private functions Public

NEW: Download demo files Not sure what to title this - essentially, inspired by RubberDuck's unit test engine, I've created a way to call private methods of standard modules in VBA. It also lets you ...
Greedo's user avatar
  • 2,445
2 votes
2 answers
245 views

C library implementing binary trees

This is my first attempt at writing a library in C. I have only included tree creation and in-order traversal function for now, but will expand to have more functions soon. I have three files, ...
Vedant Jadhav's user avatar
2 votes
1 answer
632 views

red black tree implementation in cpp

I am learning algorithms and trying to implement them in c++, I have chosen to try to implement a red-black tree due to its self-balancing properties and its ability to stop the worst case of O(n) ...
paigelarry342's user avatar
3 votes
2 answers
557 views

Simple string manipulation in C (for small microcontrollers)

Although I have long experience of other languages, I've not used C until playing around with microcontrollers using the Arduino IDE. I'm a bit uncomfortable with my use of pointers in conjunction ...
RedGrittyBrick's user avatar
5 votes
2 answers
837 views

C++ Garbage Collector - Simple Automatic Memory Management

I made a general smart pointer which fixes the problems of loops between std::shared_ptr's. While use is simple, I feel that my code is inefficient and clumsy. Here ...
Captain Hatteras's user avatar

1
2 3 4 5
8